Replace skstd::exchange with std::exchange

Change-Id: Id8065e4ff7299c12b1469468dab278b771c0382d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286277
Auto-Submit: Adlai Holler <adlai@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
Adlai Holler 2020-04-29 21:11:14 -04:00 committed by Skia Commit-Bot
parent 21d1720203
commit 5ba50afeed
9 changed files with 13 additions and 45 deletions

View File

@ -1,25 +0,0 @@
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkExchange_DEFINED
#define SkExchange_DEFINED
#include <utility>
namespace skstd {
// std::exchange is in C++14
template<typename T, typename U = T>
inline static T exchange(T& obj, U&& new_val) {
T old_val = std::move(obj);
obj = std::forward<U>(new_val);
return old_val;
}
}
#endif // SkExchange_DEFINED

View File

@ -20,7 +20,6 @@
#include "include/gpu/GrContext.h"
#include "include/gpu/gl/GrGLTypes.h"
#include "include/private/GrRecordingContext.h"
#include "src/core/SkExchange.h"
#include "src/core/SkMessageBus.h"
#include "src/gpu/GrAHardwareBufferUtils.h"
#include "src/gpu/GrContextPriv.h"
@ -126,7 +125,7 @@ GrSurfaceProxyView GrAHardwareBufferImageGenerator::makeView(GrRecordingContext*
~AutoAHBRelease() { fAhb ? AHardwareBuffer_release(fAhb) : void(); }
AutoAHBRelease& operator=(AutoAHBRelease&& that) {
fAhb = skstd::exchange(that.fAhb, nullptr);
fAhb = std::exchange(that.fAhb, nullptr);
return *this;
}
AutoAHBRelease& operator=(const AutoAHBRelease&) = delete;

View File

@ -8,7 +8,6 @@
#include "src/gpu/GrOpsTask.h"
#include "include/private/GrRecordingContext.h"
#include "src/core/SkExchange.h"
#include "src/core/SkRectPriv.h"
#include "src/core/SkScopeExit.h"
#include "src/core/SkTraceEvent.h"
@ -273,7 +272,7 @@ bool GrOpsTask::OpChain::tryConcat(
SkASSERT(first);
return false;
case GrOp::CombineResult::kMayChain:
fList = DoConcat(std::move(fList), skstd::exchange(*list, List()), caps, arenas,
fList = DoConcat(std::move(fList), std::exchange(*list, List()), caps, arenas,
auditTrail);
// The above exchange cleared out 'list'. The list needs to be empty now for the
// loop to terminate.

View File

@ -11,7 +11,6 @@
#include "include/private/GrSingleOwner.h"
#include "include/private/SkTo.h"
#include "include/utils/SkRandom.h"
#include "src/core/SkExchange.h"
#include "src/core/SkMessageBus.h"
#include "src/core/SkOpts.h"
#include "src/core/SkScopeExit.h"
@ -78,14 +77,14 @@ inline GrResourceCache::TextureAwaitingUnref::TextureAwaitingUnref(GrTexture* te
: fTexture(texture), fNumUnrefs(1) {}
inline GrResourceCache::TextureAwaitingUnref::TextureAwaitingUnref(TextureAwaitingUnref&& that) {
fTexture = skstd::exchange(that.fTexture, nullptr);
fNumUnrefs = skstd::exchange(that.fNumUnrefs, 0);
fTexture = std::exchange(that.fTexture, nullptr);
fNumUnrefs = std::exchange(that.fNumUnrefs, 0);
}
inline GrResourceCache::TextureAwaitingUnref& GrResourceCache::TextureAwaitingUnref::operator=(
TextureAwaitingUnref&& that) {
fTexture = skstd::exchange(that.fTexture, nullptr);
fNumUnrefs = skstd::exchange(that.fNumUnrefs, 0);
fTexture = std::exchange(that.fTexture, nullptr);
fNumUnrefs = std::exchange(that.fNumUnrefs, 0);
return *this;
}

View File

@ -10,7 +10,6 @@
#include "include/private/SkIDChangeListener.h"
#include "include/private/SkTHash.h"
#include "src/core/SkExchange.h"
#include "src/core/SkTInternalLList.h"
#include "src/gpu/ccpr/GrCCAtlas.h"
#include "src/gpu/ccpr/GrCCPathProcessor.h"
@ -89,14 +88,14 @@ public:
public:
static OnFlushEntryRef OnFlushRef(GrCCPathCacheEntry*);
OnFlushEntryRef() = default;
OnFlushEntryRef(OnFlushEntryRef&& ref) : fEntry(skstd::exchange(ref.fEntry, nullptr)) {}
OnFlushEntryRef(OnFlushEntryRef&& ref) : fEntry(std::exchange(ref.fEntry, nullptr)) {}
~OnFlushEntryRef();
GrCCPathCacheEntry* get() const { return fEntry; }
GrCCPathCacheEntry* operator->() const { return fEntry; }
GrCCPathCacheEntry& operator*() const { return *fEntry; }
explicit operator bool() const { return fEntry; }
void operator=(OnFlushEntryRef&& ref) { fEntry = skstd::exchange(ref.fEntry, nullptr); }
void operator=(OnFlushEntryRef&& ref) { fEntry = std::exchange(ref.fEntry, nullptr); }
private:
OnFlushEntryRef(GrCCPathCacheEntry* entry) : fEntry(entry) {}
@ -359,7 +358,7 @@ inline GrCCPathCache::HashNode::~HashNode() {
inline void GrCCPathCache::HashNode::operator=(HashNode&& node) {
SkASSERT(!fEntry || fEntry->hasBeenEvicted()); // Should have called GrCCPathCache::evict().
fEntry = skstd::exchange(node.fEntry, nullptr);
fEntry = std::exchange(node.fEntry, nullptr);
}
inline void GrCCPathProcessor::Instance::set(

View File

@ -559,7 +559,7 @@ bool GrCCPerFlushResources::finalize(GrOnFlushResourceProvider* onFlushRP) {
for (sk_sp<GrTexture>& texture : fRecyclableAtlasTextures) {
if (texture && atlas.currentHeight() == texture->height() &&
atlas.currentWidth() == texture->width()) {
backingTexture = skstd::exchange(texture, nullptr);
backingTexture = std::exchange(texture, nullptr);
break;
}
}

View File

@ -12,7 +12,6 @@
#include "include/core/SkRect.h"
#include "include/gpu/mock/GrMockTypes.h"
#include "include/private/GrRecordingContext.h"
#include "src/core/SkExchange.h"
#include "src/core/SkPathPriv.h"
#include "src/gpu/GrClip.h"
#include "src/gpu/GrContextPriv.h"
@ -171,7 +170,7 @@ public:
return;
}
CCPRPathDrawer ccpr(skstd::exchange(mockContext, nullptr), reporter, doStroke);
CCPRPathDrawer ccpr(std::exchange(mockContext, nullptr), reporter, doStroke);
if (!ccpr.valid()) {
return;
}

View File

@ -8,7 +8,6 @@
#include "tests/Test.h"
#include "include/gpu/mock/GrMockTypes.h"
#include "src/core/SkExchange.h"
#include "src/core/SkRectPriv.h"
#include "src/gpu/GrClip.h"
#include "src/gpu/GrContextPriv.h"
@ -261,7 +260,7 @@ DEF_GPUTEST(LazyProxyReleaseTest, reporter, /* options */) {
~TestCallback() { fValue ? (void)(*fValue = -1) : void(); }
TestCallback& operator=(TestCallback&& that) {
fValue = skstd::exchange(that.fValue, nullptr);
fValue = std::exchange(that.fValue, nullptr);
return *this;
}
TestCallback& operator=(const TestCallback& that) = delete;

View File

@ -9,7 +9,6 @@
#define GpuTimer_DEFINED
#include "include/core/SkTypes.h"
#include "src/core/SkExchange.h"
#include <chrono>
@ -51,7 +50,7 @@ public:
PlatformTimerQuery SK_WARN_UNUSED_RESULT queueStop() {
SkASSERT(fActiveTimer);
this->onQueueTimerStop(fActiveTimer);
return skstd::exchange(fActiveTimer, kInvalidTimerQuery);
return std::exchange(fActiveTimer, kInvalidTimerQuery);
}
enum class QueryStatus {