Commit 3dd3d3f5 authored by Bartek Nowierski's avatar Bartek Nowierski Committed by Commit Bot

Avoid unnecessary std::swap

The old code is undesirable, because:

1. It was not following go/totw/28 advice about using the following
   pattern:

      VideoDecodeAccelerator::Client* client = nullptr;
      using std::swap;
      swap(client, client_);

2. Is not really needed, because the swap is with a known constant.

3. Might not compile if in the future, hypothetically the type of
   |client_| becomes |base::CheckedPtr<VideoDecodeAccelerator::Client>|.
   (this last issue may be fixable either by: A) using the new pattern
   or B) implementing |swap(T*&, CheckedPtr<T>&)| function in the base
   namespace).

Bug: 1080832
Change-Id: I937a60cae6d9d164b088227cca209f4bcc0473a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2435171
Auto-Submit: Bartek Nowierski <bartekn@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811338}
parent 65d5d583
......@@ -58,8 +58,8 @@ void ScopedHardwareBufferHandle::reset() {
}
AHardwareBuffer* ScopedHardwareBufferHandle::Take() {
AHardwareBuffer* buffer = nullptr;
std::swap(buffer, buffer_);
AHardwareBuffer* buffer = buffer_;
buffer_ = nullptr;
return buffer;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment