Bug 1654992 - Use std::move instead of SwapElements where possible. r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D84807
This commit is contained in:
Simon Giesecke 2020-08-03 14:54:18 +00:00
parent 3db287778f
commit 032d2ac9d3
134 changed files with 328 additions and 412 deletions

View File

@ -268,8 +268,7 @@ void EventQueue::CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent,
void EventQueue::ProcessEventQueue() {
// Process only currently queued events.
nsTArray<RefPtr<AccEvent> > events;
events.SwapElements(mEvents);
const nsTArray<RefPtr<AccEvent> > events = std::move(mEvents);
uint32_t eventCount = events.Length();
#ifdef A11Y_LOG

View File

@ -827,8 +827,8 @@ void NotificationController::WillRefresh(mozilla::TimeStamp aTime) {
// etc. Therefore, they must be processed after relocations, since relocated
// subtrees might not have been created before relocation processing and the
// target might be inside a relocated subtree.
nsTArray<RefPtr<Notification>> notifications;
notifications.SwapElements(mNotifications);
const nsTArray<RefPtr<Notification>> notifications =
std::move(mNotifications);
uint32_t notificationCount = notifications.Length();
for (uint32_t idx = 0; idx < notificationCount; idx++) {

View File

@ -177,7 +177,7 @@ static void AddRelation(Accessible* aAcc, RelationType aType,
if (!targets.IsEmpty()) {
RelationTargets* newRelation = aTargets->AppendElement(
RelationTargets(static_cast<uint32_t>(aType), nsTArray<uint64_t>()));
newRelation->Targets().SwapElements(targets);
newRelation->Targets() = std::move(targets);
}
}

View File

@ -163,7 +163,7 @@ void ObservedDocShell::PopMarkers(
}
}
mTimelineMarkers.SwapElements(keptStartMarkers);
mTimelineMarkers = std::move(keptStartMarkers);
}
} // namespace mozilla

View File

@ -156,8 +156,7 @@ class AnimationEventDispatcher final {
SortEvents();
EventArray events;
mPendingEvents.SwapElements(events);
EventArray events = std::move(mPendingEvents);
// mIsSorted will be set to true by SortEvents above, and we leave it
// that way since mPendingEvents is now empty
for (AnimationEventInfo& info : events) {

View File

@ -881,7 +881,7 @@ nsTArray<AnimationProperty> KeyframeEffect::BuildProperties(
" should not be modified");
#endif
mKeyframes.SwapElements(keyframesCopy);
mKeyframes = std::move(keyframesCopy);
return result;
}

View File

@ -256,8 +256,7 @@ void DOMIntersectionObserver::Disconnect() {
void DOMIntersectionObserver::TakeRecords(
nsTArray<RefPtr<DOMIntersectionObserverEntry>>& aRetVal) {
aRetVal.SwapElements(mQueuedEntries);
mQueuedEntries.Clear();
aRetVal = std::move(mQueuedEntries);
}
static Maybe<nsRect> EdgeInclusiveIntersection(const nsRect& aRect,

View File

@ -6262,7 +6262,7 @@ void Document::UpdateFrameRequestCallbackSchedulingState(
void Document::TakeFrameRequestCallbacks(nsTArray<FrameRequest>& aCallbacks) {
MOZ_ASSERT(aCallbacks.IsEmpty());
aCallbacks.SwapElements(mFrameRequestCallbacks);
aCallbacks = std::move(mFrameRequestCallbacks);
mCanceledFrameRequestCallbacks.clear();
// No need to manually remove ourselves from the refresh driver; it will
// handle that part. But we do have to update our state.
@ -8573,8 +8573,8 @@ void Document::MaybeInitializeFinalizeFrameLoaders() {
uint32_t length = mFrameLoaderFinalizers.Length();
if (length > 0) {
nsTArray<nsCOMPtr<nsIRunnable>> finalizers;
mFrameLoaderFinalizers.SwapElements(finalizers);
nsTArray<nsCOMPtr<nsIRunnable>> finalizers =
std::move(mFrameLoaderFinalizers);
for (uint32_t i = 0; i < length; ++i) {
finalizers[i]->Run();
}
@ -11687,10 +11687,9 @@ bool Document::IsDocumentRightToLeft() {
class nsDelayedEventDispatcher : public Runnable {
public:
explicit nsDelayedEventDispatcher(nsTArray<nsCOMPtr<Document>>& aDocuments)
: mozilla::Runnable("nsDelayedEventDispatcher") {
mDocuments.SwapElements(aDocuments);
}
explicit nsDelayedEventDispatcher(nsTArray<nsCOMPtr<Document>>&& aDocuments)
: mozilla::Runnable("nsDelayedEventDispatcher"),
mDocuments(std::move(aDocuments)) {}
virtual ~nsDelayedEventDispatcher() = default;
NS_IMETHOD Run() override {
@ -11722,7 +11721,8 @@ void Document::UnsuppressEventHandlingAndFireEvents(bool aFireEvents) {
if (aFireEvents) {
MOZ_RELEASE_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIRunnable> ded = new nsDelayedEventDispatcher(documents);
nsCOMPtr<nsIRunnable> ded =
new nsDelayedEventDispatcher(std::move(documents));
Dispatch(TaskCategory::Other, ded.forget());
} else {
FireOrClearDelayedEvents(documents, false);
@ -11730,8 +11730,8 @@ void Document::UnsuppressEventHandlingAndFireEvents(bool aFireEvents) {
if (!EventHandlingSuppressed()) {
MOZ_ASSERT(NS_IsMainThread());
nsTArray<RefPtr<net::ChannelEventQueue>> queues;
mSuspendedQueues.SwapElements(queues);
nsTArray<RefPtr<net::ChannelEventQueue>> queues =
std::move(mSuspendedQueues);
for (net::ChannelEventQueue* queue : queues) {
queue->Resume();
}
@ -11767,8 +11767,8 @@ bool Document::SuspendPostMessageEvent(PostMessageEvent* aEvent) {
}
void Document::FireOrClearPostMessageEvents(bool aFireEvents) {
nsTArray<RefPtr<PostMessageEvent>> events;
events.SwapElements(mSuspendedPostMessageEvents);
nsTArray<RefPtr<PostMessageEvent>> events =
std::move(mSuspendedPostMessageEvents);
if (aFireEvents) {
for (PostMessageEvent* event : events) {

View File

@ -711,8 +711,7 @@ void VibrateWindowListener::RemoveListener() {
void Navigator::SetVibrationPermission(bool aPermitted, bool aPersistent) {
MOZ_ASSERT(NS_IsMainThread());
nsTArray<uint32_t> pattern;
pattern.SwapElements(mRequestedVibrationPattern);
nsTArray<uint32_t> pattern = std::move(mRequestedVibrationPattern);
if (!mWindow) {
return;
@ -787,7 +786,7 @@ bool Navigator::Vibrate(const nsTArray<uint32_t>& aPattern) {
return true;
}
mRequestedVibrationPattern.SwapElements(pattern);
mRequestedVibrationPattern = std::move(pattern);
PermissionDelegateHandler* permissionHandler =
doc->GetPermissionDelegateHandler();

View File

@ -29,8 +29,7 @@ void SameProcessMessageQueue::Push(Runnable* aRunnable) {
}
void SameProcessMessageQueue::Flush() {
nsTArray<RefPtr<Runnable>> queue;
mQueue.SwapElements(queue);
const nsTArray<RefPtr<Runnable>> queue = std::move(mQueue);
for (size_t i = 0; i < queue.Length(); i++) {
queue[i]->Run();
}

View File

@ -97,8 +97,7 @@ inline bool TreeIterator<ChildIterator>::Seek(nsIContent& aContent) {
parentIterators.Reverse();
mParentIterators.Clear();
mParentIterators.SwapElements(parentIterators);
mParentIterators = std::move(parentIterators);
mCurrent = &aContent;
return true;
}

View File

@ -6074,7 +6074,7 @@ void* nsContentUtils::AllocClassMatchingInfo(nsINode* aRootNode,
// nsAttrValue::Equals is sensitive to order, so we'll send an array
auto* info = new ClassMatchingInfo;
if (attrValue.Type() == nsAttrValue::eAtomArray) {
info->mClasses.SwapElements(*(attrValue.GetAtomArrayValue()));
info->mClasses = std::move(*(attrValue.GetAtomArrayValue()));
} else if (attrValue.Type() == nsAttrValue::eAtom) {
info->mClasses.AppendElement(attrValue.GetAtomValue());
}

View File

@ -88,10 +88,9 @@ namespace {
class UnlinkHostObjectURIsRunnable final : public mozilla::Runnable {
public:
explicit UnlinkHostObjectURIsRunnable(nsTArray<nsCString>& aURIs)
: mozilla::Runnable("UnlinkHostObjectURIsRunnable") {
mURIs.SwapElements(aURIs);
}
explicit UnlinkHostObjectURIsRunnable(nsTArray<nsCString>&& aURIs)
: mozilla::Runnable("UnlinkHostObjectURIsRunnable"),
mURIs(std::move(aURIs)) {}
NS_IMETHOD Run() override {
MOZ_ASSERT(NS_IsMainThread());
@ -106,7 +105,7 @@ class UnlinkHostObjectURIsRunnable final : public mozilla::Runnable {
private:
~UnlinkHostObjectURIsRunnable() = default;
nsTArray<nsCString> mURIs;
const nsTArray<nsCString> mURIs;
};
} // namespace
@ -122,7 +121,7 @@ void nsIGlobalObject::UnlinkObjectsInGlobal() {
mHostObjectURIs.Clear();
} else {
RefPtr<UnlinkHostObjectURIsRunnable> runnable =
new UnlinkHostObjectURIsRunnable(mHostObjectURIs);
new UnlinkHostObjectURIsRunnable(std::move(mHostObjectURIs));
MOZ_ASSERT(mHostObjectURIs.IsEmpty());
nsresult rv = NS_DispatchToMainThread(runnable);

View File

@ -15943,11 +15943,11 @@ class CGNativeMember(ClassMethod):
if (${declName}.IsNull()) {
aRetVal.SetNull();
} else {
aRetVal.SetValue().SwapElements(${declName}.Value());
aRetVal.SetValue() = std::move(${declName}.Value());
}
""")
else:
returnCode = "aRetVal.SwapElements(${declName});\n"
returnCode = "aRetVal = std::move(${declName});\n"
return "void", "", returnCode
if type.isRecord():
# If we want to handle record-of-record return values, we're

View File

@ -41,7 +41,7 @@ void ConsoleReportCollector::FlushReportsToConsole(uint64_t aInnerWindowID,
{
MutexAutoLock lock(mMutex);
if (aAction == ReportAction::Forget) {
mPendingReports.SwapElements(reports);
reports = std::move(mPendingReports);
} else {
reports = mPendingReports.Clone();
}
@ -90,7 +90,7 @@ void ConsoleReportCollector::FlushReportsToConsoleForServiceWorkerScope(
{
MutexAutoLock lock(mMutex);
if (aAction == ReportAction::Forget) {
mPendingReports.SwapElements(reports);
reports = std::move(mPendingReports);
} else {
reports = mPendingReports.Clone();
}
@ -153,7 +153,7 @@ void ConsoleReportCollector::FlushConsoleReports(
{
MutexAutoLock lock(mMutex);
mPendingReports.SwapElements(reports);
reports = std::move(mPendingReports);
}
for (uint32_t i = 0; i < reports.Length(); ++i) {
@ -174,7 +174,7 @@ void ConsoleReportCollector::StealConsoleReports(
{
MutexAutoLock lock(mMutex);
mPendingReports.SwapElements(reports);
reports = std::move(mPendingReports);
}
for (const PendingReport& report : reports) {

View File

@ -849,7 +849,7 @@ nsresult EventDispatcher::Dispatch(nsISupports* aTarget,
if (!sCachedMainThreadChain) {
sCachedMainThreadChain = new nsTArray<EventTargetChainItem>();
}
chain.SwapElements(*sCachedMainThreadChain);
chain = std::move(*sCachedMainThreadChain);
chain.SetCapacity(128);
}

View File

@ -225,7 +225,7 @@ RemoteLazyInputStreamChild::CreateStream() {
// Move over our local state onto the new actor object.
newActor->mWorkerRef = mWorkerRef;
newActor->mState = eInactiveMigrating;
newActor->mPendingOperations.SwapElements(mPendingOperations);
newActor->mPendingOperations = std::move(mPendingOperations);
// Create the actual stream object.
stream = new RemoteLazyInputStream(newActor);

View File

@ -1007,8 +1007,8 @@ void FileHandleThreadPool::DirectoryInfo::RemoveFileHandleQueue(
MOZ_ASSERT(mFileHandleQueues.Length() == fileHandleCount - 1,
"Didn't find the file handle we were looking for!");
nsTArray<DelayedEnqueueInfo> delayedEnqueueInfos;
delayedEnqueueInfos.SwapElements(mDelayedEnqueueInfos);
nsTArray<DelayedEnqueueInfo> delayedEnqueueInfos =
std::move(mDelayedEnqueueInfos);
for (uint32_t index = 0; index < delayedEnqueueInfos.Length(); index++) {
DelayedEnqueueInfo& delayedEnqueueInfo = delayedEnqueueInfos[index];

View File

@ -252,7 +252,7 @@ FileSystemResponseValue GetDirectoryListingTaskParent::GetSuccessRequestResult(
}
FileSystemDirectoryListingResponse response;
response.data().SwapElements(inputs);
response.data() = std::move(inputs);
return response;
}

View File

@ -23,14 +23,14 @@ namespace {
class ReleaseRunnable final : public Runnable {
public:
static void MaybeReleaseOnMainThread(
nsTArray<RefPtr<Promise>>& aPromises,
nsTArray<RefPtr<GetFilesCallback>>& aCallbacks) {
nsTArray<RefPtr<Promise>>&& aPromises,
nsTArray<RefPtr<GetFilesCallback>>&& aCallbacks) {
if (NS_IsMainThread()) {
return;
}
RefPtr<ReleaseRunnable> runnable =
new ReleaseRunnable(aPromises, aCallbacks);
new ReleaseRunnable(std::move(aPromises), std::move(aCallbacks));
FileSystemUtils::DispatchRunnable(nullptr, runnable.forget());
}
@ -45,12 +45,11 @@ class ReleaseRunnable final : public Runnable {
}
private:
ReleaseRunnable(nsTArray<RefPtr<Promise>>& aPromises,
nsTArray<RefPtr<GetFilesCallback>>& aCallbacks)
: Runnable("dom::ReleaseRunnable") {
mPromises.SwapElements(aPromises);
mCallbacks.SwapElements(aCallbacks);
}
ReleaseRunnable(nsTArray<RefPtr<Promise>>&& aPromises,
nsTArray<RefPtr<GetFilesCallback>>&& aCallbacks)
: Runnable("dom::ReleaseRunnable"),
mPromises(std::move(aPromises)),
mCallbacks(std::move(aCallbacks)) {}
nsTArray<RefPtr<Promise>> mPromises;
nsTArray<RefPtr<GetFilesCallback>> mCallbacks;
@ -126,7 +125,8 @@ GetFilesHelper::GetFilesHelper(bool aRecursiveFlag)
mCanceled(false) {}
GetFilesHelper::~GetFilesHelper() {
ReleaseRunnable::MaybeReleaseOnMainThread(mPromises, mCallbacks);
ReleaseRunnable::MaybeReleaseOnMainThread(std::move(mPromises),
std::move(mCallbacks));
}
void GetFilesHelper::AddPromise(Promise* aPromise) {
@ -215,16 +215,14 @@ void GetFilesHelper::OperationCompleted() {
mListingCompleted = true;
// Let's process the pending promises.
nsTArray<RefPtr<Promise>> promises;
promises.SwapElements(mPromises);
nsTArray<RefPtr<Promise>> promises = std::move(mPromises);
for (uint32_t i = 0; i < promises.Length(); ++i) {
ResolveOrRejectPromise(promises[i]);
}
// Let's process the pending callbacks.
nsTArray<RefPtr<GetFilesCallback>> callbacks;
callbacks.SwapElements(mCallbacks);
nsTArray<RefPtr<GetFilesCallback>> callbacks = std::move(mCallbacks);
for (uint32_t i = 0; i < callbacks.Length(); ++i) {
RunCallback(callbacks[i]);

View File

@ -198,7 +198,7 @@ FileSystemResponseValue GetFilesTaskParent::GetSuccessRequestResult(
}
FileSystemFilesResponse response;
response.data().SwapElements(inputs);
response.data() = std::move(inputs);
return response;
}

View File

@ -7015,7 +7015,7 @@ void HTMLInputElement::UpdateEntries(
// dropped fileEntry and directoryEntry objects.
fs->CreateRoot(entries);
mFileData->mEntries.SwapElements(entries);
mFileData->mEntries = std::move(entries);
}
void HTMLInputElement::GetWebkitEntries(

View File

@ -26245,7 +26245,7 @@ void IndexGetKeyRequestOp::GetResponse(RequestResponse& aResponse,
return old + entry.GetBuffer().Length();
});
mResponse.SwapElements(aResponse.get_IndexGetAllKeysResponse().keys());
aResponse.get_IndexGetAllKeysResponse().keys() = std::move(mResponse);
return;
}

View File

@ -95,13 +95,13 @@ struct IDBObjectStore::StructuredCloneWriteInfo {
StructuredCloneWriteInfo(StructuredCloneWriteInfo&& aCloneWriteInfo) noexcept
: mCloneBuffer(std::move(aCloneWriteInfo.mCloneBuffer)),
mFiles(std::move(aCloneWriteInfo.mFiles)),
mDatabase(aCloneWriteInfo.mDatabase),
mOffsetToKeyProp(aCloneWriteInfo.mOffsetToKeyProp) {
MOZ_ASSERT(mDatabase);
MOZ_COUNT_CTOR(StructuredCloneWriteInfo);
mFiles.SwapElements(aCloneWriteInfo.mFiles);
aCloneWriteInfo.mOffsetToKeyProp = 0;
}

View File

@ -44,12 +44,12 @@ FilePickerParent::~FilePickerParent() = default;
// the same runnable on the main thread.
// 3. The main thread sends the results over IPC.
FilePickerParent::IORunnable::IORunnable(FilePickerParent* aFPParent,
nsTArray<nsCOMPtr<nsIFile>>& aFiles,
nsTArray<nsCOMPtr<nsIFile>>&& aFiles,
bool aIsDirectory)
: mozilla::Runnable("dom::FilePickerParent::IORunnable"),
mFilePickerParent(aFPParent),
mFiles(std::move(aFiles)),
mIsDirectory(aIsDirectory) {
mFiles.SwapElements(aFiles);
MOZ_ASSERT_IF(aIsDirectory, mFiles.Length() == 1);
}
@ -165,7 +165,7 @@ void FilePickerParent::SendFilesOrDirectories(
}
InputBlobs inblobs;
inblobs.blobs().SwapElements(ipcBlobs);
inblobs.blobs() = std::move(ipcBlobs);
Unused << Send__delete__(this, inblobs, mResult);
}
@ -207,8 +207,8 @@ void FilePickerParent::Done(int16_t aResult) {
}
MOZ_ASSERT(!mRunnable);
mRunnable =
new IORunnable(this, files, mMode == nsIFilePicker::modeGetFolder);
mRunnable = new IORunnable(this, std::move(files),
mMode == nsIFilePicker::modeGetFolder);
// Dispatch to background thread to do I/O:
if (!mRunnable->Dispatch()) {

View File

@ -74,8 +74,8 @@ class FilePickerParent : public PFilePickerParent {
bool mIsDirectory;
public:
IORunnable(FilePickerParent* aFPParent, nsTArray<nsCOMPtr<nsIFile>>& aFiles,
bool aIsDirectory);
IORunnable(FilePickerParent* aFPParent,
nsTArray<nsCOMPtr<nsIFile>>&& aFiles, bool aIsDirectory);
bool Dispatch();
NS_IMETHOD Run() override;

View File

@ -1712,7 +1712,7 @@ class Datastore final
RefPtr<Connection>&& aConnection,
RefPtr<QuotaObject>&& aQuotaObject,
nsDataHashtable<nsStringHashKey, LSValue>& aValues,
nsTArray<LSItemInfo>& aOrderedItems);
nsTArray<LSItemInfo>&& aOrderedItems);
const nsCString& Origin() const { return mOrigin; }
@ -4804,10 +4804,11 @@ Datastore::Datastore(const nsACString& aGroup, const nsACString& aOrigin,
RefPtr<Connection>&& aConnection,
RefPtr<QuotaObject>&& aQuotaObject,
nsDataHashtable<nsStringHashKey, LSValue>& aValues,
nsTArray<LSItemInfo>& aOrderedItems)
nsTArray<LSItemInfo>&& aOrderedItems)
: mDirectoryLock(std::move(aDirectoryLock)),
mConnection(std::move(aConnection)),
mQuotaObject(std::move(aQuotaObject)),
mOrderedItems(std::move(aOrderedItems)),
mGroup(aGroup),
mOrigin(aOrigin),
mPrivateBrowsingId(aPrivateBrowsingId),
@ -4821,7 +4822,6 @@ Datastore::Datastore(const nsACString& aGroup, const nsACString& aOrigin,
AssertIsOnBackgroundThread();
mValues.SwapElements(aValues);
mOrderedItems.SwapElements(aOrderedItems);
}
Datastore::~Datastore() {
@ -7915,7 +7915,7 @@ void PrepareDatastoreOp::GetResponse(LSRequestResponse& aResponse) {
mDatastore = new Datastore(
mGroup, mOrigin, mPrivateBrowsingId, mUsage, mSizeOfKeys, mSizeOfItems,
std::move(mDirectoryLock), std::move(mConnection),
std::move(quotaObject), mValues, mOrderedItems);
std::move(quotaObject), mValues, std::move(mOrderedItems));
mDatastore->NoteLivePrepareDatastoreOp(this);

View File

@ -121,7 +121,7 @@ void AudioCaptureTrack::MixerCallback(AudioDataValue* aMixedBuffer,
}
AudioChunk chunk;
chunk.mBuffer =
new mozilla::SharedChannelArrayBuffer<AudioDataValue>(&output);
new mozilla::SharedChannelArrayBuffer<AudioDataValue>(std::move(output));
chunk.mDuration = aFrames;
chunk.mBufferFormat = aFormat;
chunk.mChannelData.SetLength(MONO);

View File

@ -40,9 +40,8 @@ namespace mozilla {
template <typename T>
class SharedChannelArrayBuffer : public ThreadSharedObject {
public:
explicit SharedChannelArrayBuffer(nsTArray<nsTArray<T> >* aBuffers) {
mBuffers.SwapElements(*aBuffers);
}
explicit SharedChannelArrayBuffer(nsTArray<nsTArray<T> >&& aBuffers)
: mBuffers(std::move(aBuffers)) {}
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override {
size_t amount = 0;
@ -349,7 +348,7 @@ class AudioSegment : public MediaSegmentBase<AudioSegment, AudioChunk> {
}
MOZ_ASSERT(channels > 0);
c.mDuration = output[0].Length();
c.mBuffer = new mozilla::SharedChannelArrayBuffer<T>(&output);
c.mBuffer = new mozilla::SharedChannelArrayBuffer<T>(std::move(output));
for (uint32_t i = 0; i < channels; i++) {
c.mChannelData[i] = bufferPtrs[i];
}
@ -397,7 +396,7 @@ class AudioSegment : public MediaSegmentBase<AudioSegment, AudioChunk> {
AudioChunk* AppendAndConsumeChunk(AudioChunk* aChunk) {
AudioChunk* chunk = AppendChunk(aChunk->mDuration);
chunk->mBuffer = std::move(aChunk->mBuffer);
chunk->mChannelData.SwapElements(aChunk->mChannelData);
chunk->mChannelData = std::move(aChunk->mChannelData);
MOZ_ASSERT(chunk->mBuffer || aChunk->mChannelData.IsEmpty(),
"Appending invalid data ?");

View File

@ -271,7 +271,7 @@ void AudioChunkList::CreateChunks(int aNumOfChunks, int aChannels) {
bufferPtrs[i] = ptr;
}
chunk.mBuffer = new mozilla::SharedChannelArrayBuffer(&buffer);
chunk.mBuffer = new mozilla::SharedChannelArrayBuffer(std::move(buffer));
chunk.mChannelData.AppendElements(aChannels);
for (int i = 0; i < aChannels; ++i) {
chunk.mChannelData[i] = bufferPtrs[i];

View File

@ -374,8 +374,8 @@ class MediaSegmentBase : public MediaSegment {
explicit MediaSegmentBase(Type aType) : MediaSegment(aType), mChunks() {}
MediaSegmentBase(MediaSegmentBase&& aSegment)
: MediaSegment(std::move(aSegment)), mChunks() {
mChunks.SwapElements(aSegment.mChunks);
: MediaSegment(std::move(aSegment)),
mChunks(std::move(aSegment.mChunks)) {
MOZ_ASSERT(mChunks.Capacity() >= DEFAULT_SEGMENT_CAPACITY,
"Capacity must be retained in self after swap");
MOZ_ASSERT(aSegment.mChunks.Capacity() >= DEFAULT_SEGMENT_CAPACITY,

View File

@ -1701,7 +1701,7 @@ void MediaTrackGraphImpl::RunInStableState(bool aSourceIsMTG) {
LifecycleState_str[LifecycleStateRef()]));
}
runnables.SwapElements(mUpdateRunnables);
runnables = std::move(mUpdateRunnables);
for (uint32_t i = 0; i < mTrackUpdates.Length(); ++i) {
TrackUpdate* update = &mTrackUpdates[i];
if (update->mTrack) {
@ -1729,7 +1729,7 @@ void MediaTrackGraphImpl::RunInStableState(bool aSourceIsMTG) {
} else {
if (LifecycleStateRef() <= LIFECYCLE_WAITING_FOR_MAIN_THREAD_CLEANUP) {
MessageBlock* block = mBackMessageQueue.AppendElement();
block->mMessages.SwapElements(mCurrentTaskMessageQueue);
block->mMessages = std::move(mCurrentTaskMessageQueue);
EnsureNextIteration();
}

View File

@ -815,8 +815,8 @@ const nsCString& GMPParent::GetVersion() const { return mVersion; }
uint32_t GMPParent::GetPluginId() const { return mPluginId; }
void GMPParent::ResolveGetContentParentPromises() {
nsTArray<UniquePtr<MozPromiseHolder<GetGMPContentParentPromise>>> promises;
promises.SwapElements(mGetContentParentPromises);
nsTArray<UniquePtr<MozPromiseHolder<GetGMPContentParentPromise>>> promises =
std::move(mGetContentParentPromises);
MOZ_ASSERT(mGetContentParentPromises.IsEmpty());
RefPtr<GMPContentParent::CloseBlocker> blocker(
new GMPContentParent::CloseBlocker(mGMPContentParent));
@ -852,8 +852,8 @@ bool GMPParent::OpenPGMPContent() {
}
void GMPParent::RejectGetContentParentPromises() {
nsTArray<UniquePtr<MozPromiseHolder<GetGMPContentParentPromise>>> promises;
promises.SwapElements(mGetContentParentPromises);
nsTArray<UniquePtr<MozPromiseHolder<GetGMPContentParentPromise>>> promises =
std::move(mGetContentParentPromises);
MOZ_ASSERT(mGetContentParentPromises.IsEmpty());
for (auto& holder : promises) {
holder->Reject(NS_ERROR_FAILURE, __func__);

View File

@ -401,8 +401,8 @@ void GeckoMediaPluginServiceChild::SetServiceChild(
mServiceChild = std::move(aServiceChild);
nsTArray<MozPromiseHolder<GetServiceChildPromise>> holders;
holders.SwapElements(mGetServiceChildPromises);
nsTArray<MozPromiseHolder<GetServiceChildPromise>> holders =
std::move(mGetServiceChildPromises);
for (MozPromiseHolder<GetServiceChildPromise>& holder : holders) {
holder.Resolve(mServiceChild.get(), __func__);
}

View File

@ -32,8 +32,7 @@ void WidevineBuffer::SetSize(uint32_t aSize) { mBuffer.SetLength(aSize); }
uint32_t WidevineBuffer::Size() const { return mBuffer.Length(); }
nsTArray<uint8_t> WidevineBuffer::ExtractBuffer() {
nsTArray<uint8_t> out;
out.SwapElements(mBuffer);
nsTArray<uint8_t> out = std::move(mBuffer);
return out;
}

View File

@ -254,7 +254,7 @@ void fillChunkWithStereo(AudioChunk* c, int duration) {
ch2[i] = GetHighValue<T>();
}
c->mBuffer = new mozilla::SharedChannelArrayBuffer<T>(&stereo);
c->mBuffer = new mozilla::SharedChannelArrayBuffer<T>(std::move(stereo));
c->mChannelData.SetLength(2);
c->mChannelData[0] = ch1;

View File

@ -930,7 +930,7 @@ AudioChunk CreateAudioChunk(uint32_t aFrames, int aChannels,
}
}
chunk.mBuffer = new mozilla::SharedChannelArrayBuffer(&buffer);
chunk.mBuffer = new mozilla::SharedChannelArrayBuffer(std::move(buffer));
chunk.mBufferFormat = aSampleFormat;
chunk.mChannelData.AppendElements(aChannels);
for (int i = 0; i < aChannels; ++i) {
@ -1095,7 +1095,7 @@ TEST(TestAudioResampler, InAudioSegment_Float)
}
}
chunk2.mBuffer = new mozilla::SharedChannelArrayBuffer(&buffer);
chunk2.mBuffer = new mozilla::SharedChannelArrayBuffer(std::move(buffer));
chunk2.mBufferFormat = AUDIO_FORMAT_FLOAT32;
chunk2.mChannelData.AppendElements(channels);
for (int i = 0; i < channels; ++i) {
@ -1150,7 +1150,7 @@ TEST(TestAudioResampler, InAudioSegment_Short)
}
}
chunk2.mBuffer = new mozilla::SharedChannelArrayBuffer(&buffer);
chunk2.mBuffer = new mozilla::SharedChannelArrayBuffer(std::move(buffer));
chunk2.mBufferFormat = AUDIO_FORMAT_S16;
chunk2.mChannelData.AppendElements(channels);
for (int i = 0; i < channels; ++i) {

View File

@ -210,8 +210,7 @@ RefPtr<MediaDataEncoder::EncodePromise> AndroidDataEncoder::ProcessEncode(
mJavaEncoder->Input(buffer, mInputBufferInfo, nullptr);
if (mEncodedData.Length() > 0) {
EncodedData pending;
pending.SwapElements(mEncodedData);
EncodedData pending = std::move(mEncodedData);
return EncodePromise::CreateAndResolve(std::move(pending), __func__);
} else {
return EncodePromise::CreateAndResolve(EncodedData(), __func__);
@ -317,8 +316,7 @@ void AndroidDataEncoder::ProcessOutput(
mDrainState = DrainState::DRAINED;
}
if (!mDrainPromise.IsEmpty()) {
EncodedData pending;
pending.SwapElements(mEncodedData);
EncodedData pending = std::move(mEncodedData);
mDrainPromise.Resolve(std::move(pending), __func__);
}
}
@ -389,8 +387,7 @@ RefPtr<MediaDataEncoder::EncodePromise> AndroidDataEncoder::ProcessDrain() {
[[fallthrough]];
case DrainState::DRAINED:
if (mEncodedData.Length() > 0) {
EncodedData pending;
pending.SwapElements(mEncodedData);
EncodedData pending = std::move(mEncodedData);
return EncodePromise::CreateAndResolve(std::move(pending), __func__);
} else {
return EncodePromise::CreateAndResolve(EncodedData(), __func__);

View File

@ -285,7 +285,7 @@ class AudioNodeEngine {
}
// This consumes the contents of aData. aData will be emptied after this
// returns.
virtual void SetRawArrayData(nsTArray<float>& aData) {
virtual void SetRawArrayData(nsTArray<float>&& aData) {
NS_ERROR("SetRawArrayData called on an engine that doesn't support it");
}

View File

@ -252,20 +252,19 @@ void AudioNodeTrack::SetReverb(WebCore::Reverb* aReverb,
MakeUnique<Message>(this, aReverb, aImpulseChannelCount));
}
void AudioNodeTrack::SetRawArrayData(nsTArray<float>& aData) {
void AudioNodeTrack::SetRawArrayData(nsTArray<float>&& aData) {
class Message final : public ControlMessage {
public:
Message(AudioNodeTrack* aTrack, nsTArray<float>& aData)
: ControlMessage(aTrack) {
mData.SwapElements(aData);
}
Message(AudioNodeTrack* aTrack, nsTArray<float>&& aData)
: ControlMessage(aTrack), mData(std::move(aData)) {}
void Run() override {
static_cast<AudioNodeTrack*>(mTrack)->Engine()->SetRawArrayData(mData);
static_cast<AudioNodeTrack*>(mTrack)->Engine()->SetRawArrayData(
std::move(mData));
}
nsTArray<float> mData;
};
GraphImpl()->AppendMessage(MakeUnique<Message>(this, aData));
GraphImpl()->AppendMessage(MakeUnique<Message>(this, std::move(aData)));
}
void AudioNodeTrack::SetChannelMixingParameters(

View File

@ -100,7 +100,7 @@ class AudioNodeTrack : public ProcessedMediaTrack {
const dom::AudioTimelineEvent& aEvent);
// This consumes the contents of aData. aData will be emptied after this
// returns.
void SetRawArrayData(nsTArray<float>& aData);
void SetRawArrayData(nsTArray<float>&& aData);
void SetChannelMixingParameters(uint32_t aNumberOfChannels,
ChannelCountMode aChannelCountMoe,
ChannelInterpretation aChannelInterpretation);

View File

@ -153,8 +153,8 @@ class WaveShaperNodeEngine final : public AudioNodeEngine {
enum Parameters { TYPE };
void SetRawArrayData(nsTArray<float>& aCurve) override {
mCurve.SwapElements(aCurve);
void SetRawArrayData(nsTArray<float>&& aCurve) override {
mCurve = std::move(aCurve);
}
void SetInt32Parameter(uint32_t aIndex, int32_t aValue) override {
@ -363,7 +363,7 @@ void WaveShaperNode::SendCurveToTrack() {
MOZ_ASSERT(ns, "Why don't we have a track here?");
nsTArray<float> copyCurve(mCurve.Clone());
ns->SetRawArrayData(copyCurve);
ns->SetRawArrayData(std::move(copyCurve));
}
void WaveShaperNode::GetCurve(JSContext* aCx,

View File

@ -266,7 +266,7 @@ nsReturnRef<HRTFElevation> HRTFElevation::createBuiltin(int elevation,
}
return nsReturnRef<HRTFElevation>(
new HRTFElevation(&kernelListL, elevation, sampleRate));
new HRTFElevation(std::move(kernelListL), elevation, sampleRate));
}
nsReturnRef<HRTFElevation> HRTFElevation::createByInterpolatingSlices(
@ -293,8 +293,8 @@ nsReturnRef<HRTFElevation> HRTFElevation::createByInterpolatingSlices(
double angle = (1.0 - x) * hrtfElevation1->elevationAngle() +
x * hrtfElevation2->elevationAngle();
return nsReturnRef<HRTFElevation>(
new HRTFElevation(&kernelListL, static_cast<int>(angle), sampleRate));
return nsReturnRef<HRTFElevation>(new HRTFElevation(
std::move(kernelListL), static_cast<int>(angle), sampleRate));
}
void HRTFElevation::getKernelsFromAzimuth(

View File

@ -80,10 +80,10 @@ class HRTFElevation {
HRTFElevation(const HRTFElevation& other) = delete;
void operator=(const HRTFElevation& other) = delete;
HRTFElevation(HRTFKernelList* kernelListL, int elevation, float sampleRate)
: m_elevationAngle(elevation), m_sampleRate(sampleRate) {
m_kernelListL.SwapElements(*kernelListL);
}
HRTFElevation(HRTFKernelList&& kernelListL, int elevation, float sampleRate)
: m_kernelListL(std::move(kernelListL)),
m_elevationAngle(elevation),
m_sampleRate(sampleRate) {}
// Returns the list of left ear HRTFKernels for all the azimuths going from 0
// to 360 degrees.

View File

@ -229,11 +229,11 @@ void CubebDeviceEnumerator::EnumerateAudioDevices(
bool manualInvalidation = true;
if (aSide == Side::INPUT) {
devices.SwapElements(mInputDevices);
devices = std::move(mInputDevices);
manualInvalidation = mManualInputInvalidation;
} else {
MOZ_ASSERT(aSide == Side::OUTPUT);
devices.SwapElements(mOutputDevices);
devices = std::move(mOutputDevices);
manualInvalidation = mManualOutputInvalidation;
}

View File

@ -223,7 +223,7 @@ bool MessagePortService::DisentanglePort(
// We didn't find the parent.
if (!nextParent) {
data->mMessages.SwapElements(aMessages);
data->mMessages = std::move(aMessages);
data->mWaitingForNewParent = true;
data->mParent = nullptr;
return true;

View File

@ -413,7 +413,7 @@ void TCPSocket::NotifyCopyComplete(nsresult aStatus) {
// If we have pending data, we should send them, or fire
// a drain event if we are waiting for it.
if (!mPendingDataAfterStartTLS.IsEmpty()) {
mPendingData.SwapElements(mPendingDataAfterStartTLS);
mPendingData = std::move(mPendingDataAfterStartTLS);
EnsureCopying();
return;
}

View File

@ -164,8 +164,7 @@ void TCPSocketParent::FireEvent(const nsAString& aType,
void TCPSocketParent::FireArrayBufferDataEvent(nsTArray<uint8_t>& aBuffer,
TCPReadyState aReadyState) {
nsTArray<uint8_t> arr;
arr.SwapElements(aBuffer);
nsTArray<uint8_t> arr = std::move(aBuffer);
SendableData data(arr);
SendEvent(u"data"_ns, data, aReadyState);

View File

@ -506,8 +506,7 @@ UDPSocketParent::OnPacketReceived(nsIUDPSocket* aSocket,
FireInternalError(__LINE__);
return NS_ERROR_OUT_OF_MEMORY;
}
nsTArray<uint8_t> infallibleArray;
infallibleArray.SwapElements(fallibleArray);
nsTArray<uint8_t> infallibleArray{std::move(fallibleArray)};
// compose callback
mozilla::Unused << SendCallbackReceivedData(UDPAddressInfo(ip, port),

View File

@ -285,7 +285,7 @@ void PerformanceObserver::Observe(const PerformanceObserverInit& aOptions,
if (!didUpdateOptionsList) {
updatedOptionsList.AppendElement(aOptions);
}
mOptions.SwapElements(updatedOptionsList);
mOptions = std::move(updatedOptionsList);
/* 3.3.1.6.5 */
if (maybeBuffered.WasPassed() && maybeBuffered.Value()) {
@ -354,5 +354,5 @@ void PerformanceObserver::Disconnect() {
void PerformanceObserver::TakeRecords(
nsTArray<RefPtr<PerformanceEntry>>& aRetval) {
MOZ_ASSERT(aRetval.IsEmpty());
aRetval.SwapElements(mQueuedEntries);
aRetval = std::move(mQueuedEntries);
}

View File

@ -1222,11 +1222,9 @@ class FinalizeOriginEvictionOp : public OriginOperationBase {
public:
FinalizeOriginEvictionOp(nsIEventTarget* aBackgroundThread,
nsTArray<RefPtr<DirectoryLockImpl>>& aLocks)
: OriginOperationBase(aBackgroundThread) {
nsTArray<RefPtr<DirectoryLockImpl>>&& aLocks)
: OriginOperationBase(aBackgroundThread), mLocks(std::move(aLocks)) {
MOZ_ASSERT(!NS_IsMainThread());
mLocks.SwapElements(aLocks);
}
void Dispatch();
@ -3524,7 +3522,7 @@ bool QuotaObject::LockedMaybeUpdateSize(int64_t aSize, bool aTruncate) {
// However, the origin eviction must be finalized in this case too.
MutexAutoUnlock autoUnlock(quotaManager->mQuotaMutex);
quotaManager->FinalizeOriginEviction(locks);
quotaManager->FinalizeOriginEviction(std::move(locks));
return false;
}
@ -3557,7 +3555,7 @@ bool QuotaObject::LockedMaybeUpdateSize(int64_t aSize, bool aTruncate) {
// ops for the evicted origins.
MutexAutoUnlock autoUnlock(quotaManager->mQuotaMutex);
quotaManager->FinalizeOriginEviction(locks);
quotaManager->FinalizeOriginEviction(std::move(locks));
return true;
}
@ -7789,11 +7787,11 @@ void QuotaManager::DeleteFilesForOrigin(PersistenceType aPersistenceType,
}
void QuotaManager::FinalizeOriginEviction(
nsTArray<RefPtr<DirectoryLockImpl>>& aLocks) {
nsTArray<RefPtr<DirectoryLockImpl>>&& aLocks) {
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
RefPtr<FinalizeOriginEvictionOp> op =
new FinalizeOriginEvictionOp(mOwningThread, aLocks);
new FinalizeOriginEvictionOp(mOwningThread, std::move(aLocks));
if (IsOnIOThread()) {
op->RunOnIOThreadImmediately();
@ -9361,12 +9359,7 @@ void GetUsageOp::GetResponse(UsageRequestResponse& aResponse) {
aResponse = AllUsageResponse();
if (!mOriginUsages.IsEmpty()) {
nsTArray<OriginUsage>& originUsages =
aResponse.get_AllUsageResponse().originUsages();
mOriginUsages.SwapElements(originUsages);
}
aResponse.get_AllUsageResponse().originUsages() = std::move(mOriginUsages);
}
GetOriginUsageOp::GetOriginUsageOp(const UsageRequestParams& aParams)

View File

@ -563,7 +563,7 @@ class QuotaManager final : public BackgroundThreadObject {
void DeleteFilesForOrigin(PersistenceType aPersistenceType,
const nsACString& aOrigin);
void FinalizeOriginEviction(nsTArray<RefPtr<DirectoryLockImpl>>& aLocks);
void FinalizeOriginEviction(nsTArray<RefPtr<DirectoryLockImpl>>&& aLocks);
void ReleaseIOThreadObjects() {
AssertIsOnIOThread();

View File

@ -339,8 +339,7 @@ NS_IMETHODIMP
ReportDeliver::Notify(nsITimer* aTimer) {
mTimer = nullptr;
nsTArray<ReportData> reports;
reports.SwapElements(mReportQueue);
nsTArray<ReportData> reports = std::move(mReportQueue);
// group reports by endpoint and nsIPrincipal
std::map<std::pair<nsCString, nsCOMPtr<nsIPrincipal>>, nsTArray<ReportData>>

View File

@ -136,8 +136,7 @@ void ReportingObserver::MaybeNotify() {
}
// Let's take the ownership of the reports.
nsTArray<RefPtr<Report>> list;
list.SwapElements(mReports);
nsTArray<RefPtr<Report>> list = std::move(mReports);
Sequence<OwningNonNull<Report>> reports;
for (Report* report : list) {

View File

@ -150,7 +150,7 @@ bool FeaturePolicyParser::ParseString(const nsAString& aPolicy,
}
}
aParsedFeatures.SwapElements(parsedFeatures);
aParsedFeatures = std::move(parsedFeatures);
return true;
}

View File

@ -29,7 +29,7 @@ void CheckParser(const nsAString& aInput, bool aExpectedResults,
aExpectedResults);
ASSERT_TRUE(parsedFeatures.Length() == aExpectedFeatures);
parsedFeatures.SwapElements(aParsedFeatures);
aParsedFeatures = std::move(parsedFeatures);
}
TEST(FeaturePolicyParser, Basic)

View File

@ -50,8 +50,8 @@ void ServiceWorkerJob::StealResultCallbacksFrom(ServiceWorkerJob* aJob) {
// Take the callbacks from the other job immediately to avoid the
// any possibility of them existing on both jobs at once.
nsTArray<RefPtr<Callback>> callbackList;
callbackList.SwapElements(aJob->mResultCallbackList);
nsTArray<RefPtr<Callback>> callbackList =
std::move(aJob->mResultCallbackList);
for (RefPtr<Callback>& callback : callbackList) {
// Use AppendResultCallback() so that assertion checking is performed on
@ -138,8 +138,7 @@ void ServiceWorkerJob::InvokeResultCallbacks(ErrorResult& aRv) {
MOZ_DIAGNOSTIC_ASSERT(!mResultCallbacksInvoked);
mResultCallbacksInvoked = true;
nsTArray<RefPtr<Callback>> callbackList;
callbackList.SwapElements(mResultCallbackList);
nsTArray<RefPtr<Callback>> callbackList = std::move(mResultCallbackList);
for (RefPtr<Callback>& callback : callbackList) {
// The callback might consume an exception on the ErrorResult, so we need

View File

@ -1373,8 +1373,8 @@ RefPtr<ServiceWorkerRegistrationPromise> ServiceWorkerManager::WhenReady(
}
void ServiceWorkerManager::CheckPendingReadyPromises() {
nsTArray<UniquePtr<PendingReadyData>> pendingReadyList;
mPendingReadyList.SwapElements(pendingReadyList);
nsTArray<UniquePtr<PendingReadyData>> pendingReadyList =
std::move(mPendingReadyList);
for (uint32_t i = 0; i < pendingReadyList.Length(); ++i) {
UniquePtr<PendingReadyData> prd(std::move(pendingReadyList[i]));
@ -1391,8 +1391,8 @@ void ServiceWorkerManager::CheckPendingReadyPromises() {
void ServiceWorkerManager::RemovePendingReadyPromise(
const ClientInfo& aClientInfo) {
nsTArray<UniquePtr<PendingReadyData>> pendingReadyList;
mPendingReadyList.SwapElements(pendingReadyList);
nsTArray<UniquePtr<PendingReadyData>> pendingReadyList =
std::move(mPendingReadyList);
for (uint32_t i = 0; i < pendingReadyList.Length(); ++i) {
UniquePtr<PendingReadyData> prd(std::move(pendingReadyList[i]));

View File

@ -1807,8 +1807,8 @@ void ServiceWorkerPrivate::TerminateWorker() {
// Any pending events are never going to fire on this worker. Cancel
// them so that intercepted channels can be reset and other resources
// cleaned up.
nsTArray<RefPtr<WorkerRunnable>> pendingEvents;
mPendingFunctionalEvents.SwapElements(pendingEvents);
nsTArray<RefPtr<WorkerRunnable>> pendingEvents =
std::move(mPendingFunctionalEvents);
for (uint32_t i = 0; i < pendingEvents.Length(); ++i) {
pendingEvents[i]->Cancel();
}
@ -1868,8 +1868,8 @@ void ServiceWorkerPrivate::UpdateState(ServiceWorkerState aState) {
return;
}
nsTArray<RefPtr<WorkerRunnable>> pendingEvents;
mPendingFunctionalEvents.SwapElements(pendingEvents);
nsTArray<RefPtr<WorkerRunnable>> pendingEvents =
std::move(mPendingFunctionalEvents);
for (uint32_t i = 0; i < pendingEvents.Length(); ++i) {
RefPtr<WorkerRunnable> r = std::move(pendingEvents[i]);

View File

@ -161,8 +161,8 @@ void ServiceWorkerRegistration::UpdateState(
UpdateStateInternal(aDescriptor.GetInstalling(), aDescriptor.GetWaiting(),
aDescriptor.GetActive());
nsTArray<UniquePtr<VersionCallback>> callbackList;
mVersionCallbackList.SwapElements(callbackList);
nsTArray<UniquePtr<VersionCallback>> callbackList =
std::move(mVersionCallbackList);
for (auto& cb : callbackList) {
if (cb->mVersion > mDescriptor.Version()) {
mVersionCallbackList.AppendElement(std::move(cb));

View File

@ -421,8 +421,7 @@ void ServiceWorkerRegistrationInfo::UpdateRegistrationState(
TimeStamp oldest = TimeStamp::Now() - TimeDuration::FromSeconds(30);
if (!mVersionList.IsEmpty() && mVersionList[0]->mTimeStamp < oldest) {
nsTArray<UniquePtr<VersionEntry>> list;
mVersionList.SwapElements(list);
nsTArray<UniquePtr<VersionEntry>> list = std::move(mVersionList);
for (auto& entry : list) {
if (entry->mTimeStamp >= oldest) {
mVersionList.AppendElement(std::move(entry));

View File

@ -767,7 +767,7 @@ nsresult SMILAnimationFunction::GetValues(const SMILAttr& aSMILAttr,
}
}
result.SwapElements(aResult);
aResult = std::move(result);
return NS_OK;
}

View File

@ -182,8 +182,7 @@ void SMILTimedElement::RemoveInstanceTimes(InstanceTimeList& aArray,
newArray.AppendElement(item);
}
}
aArray.Clear();
aArray.SwapElements(newArray);
aArray = std::move(newArray);
}
//----------------------------------------------------------------------
@ -1418,8 +1417,7 @@ void SMILTimedElement::FilterIntervals() {
filteredList.AppendElement(std::move(mOldIntervals[i]));
}
}
mOldIntervals.Clear();
mOldIntervals.SwapElements(filteredList);
mOldIntervals = std::move(filteredList);
}
namespace {

View File

@ -446,7 +446,7 @@ nsresult URLParams::Sort() {
}
}
mParams.SwapElements(params);
mParams = std::move(params);
return NS_OK;
}

View File

@ -37,12 +37,11 @@ class MainThreadReleaseRunnable final : public Runnable {
nsCOMPtr<nsILoadGroup> mLoadGroupToCancel;
public:
MainThreadReleaseRunnable(nsTArray<nsCOMPtr<nsISupports>>& aDoomed,
nsCOMPtr<nsILoadGroup>& aLoadGroupToCancel)
: mozilla::Runnable("MainThreadReleaseRunnable") {
mDoomed.SwapElements(aDoomed);
mLoadGroupToCancel.swap(aLoadGroupToCancel);
}
MainThreadReleaseRunnable(nsTArray<nsCOMPtr<nsISupports>>&& aDoomed,
nsCOMPtr<nsILoadGroup>&& aLoadGroupToCancel)
: mozilla::Runnable("MainThreadReleaseRunnable"),
mDoomed(std::move(aDoomed)),
mLoadGroupToCancel(std::move(aLoadGroupToCancel)) {}
NS_INLINE_DECL_REFCOUNTING_INHERITED(MainThreadReleaseRunnable, Runnable)
@ -363,11 +362,13 @@ bool WorkerLoadInfo::PrincipalURIMatchesScriptURL() {
bool WorkerLoadInfo::ProxyReleaseMainThreadObjects(
WorkerPrivate* aWorkerPrivate) {
nsCOMPtr<nsILoadGroup> nullLoadGroup;
return ProxyReleaseMainThreadObjects(aWorkerPrivate, nullLoadGroup);
return ProxyReleaseMainThreadObjects(aWorkerPrivate,
std::move(nullLoadGroup));
}
bool WorkerLoadInfo::ProxyReleaseMainThreadObjects(
WorkerPrivate* aWorkerPrivate, nsCOMPtr<nsILoadGroup>& aLoadGroupToCancel) {
WorkerPrivate* aWorkerPrivate,
nsCOMPtr<nsILoadGroup>&& aLoadGroupToCancel) {
static const uint32_t kDoomedCount = 11;
nsTArray<nsCOMPtr<nsISupports>> doomed(kDoomedCount);
@ -386,8 +387,8 @@ bool WorkerLoadInfo::ProxyReleaseMainThreadObjects(
MOZ_ASSERT(doomed.Length() == kDoomedCount);
RefPtr<MainThreadReleaseRunnable> runnable =
new MainThreadReleaseRunnable(doomed, aLoadGroupToCancel);
RefPtr<MainThreadReleaseRunnable> runnable = new MainThreadReleaseRunnable(
std::move(doomed), std::move(aLoadGroupToCancel));
return NS_SUCCEEDED(aWorkerPrivate->DispatchToMainThread(runnable.forget()));
}

View File

@ -180,7 +180,7 @@ struct WorkerLoadInfo : WorkerLoadInfoData {
bool ProxyReleaseMainThreadObjects(
WorkerPrivate* aWorkerPrivate,
nsCOMPtr<nsILoadGroup>& aLoadGroupToCancel);
nsCOMPtr<nsILoadGroup>&& aLoadGroupToCancel);
};
} // namespace dom

View File

@ -1807,8 +1807,8 @@ bool WorkerPrivate::ProxyReleaseMainThreadObjects() {
mLoadInfo.mLoadGroup.swap(loadGroupToCancel);
}
bool result =
mLoadInfo.ProxyReleaseMainThreadObjects(this, loadGroupToCancel);
bool result = mLoadInfo.ProxyReleaseMainThreadObjects(
this, std::move(loadGroupToCancel));
mMainThreadObjectsForgotten = true;

View File

@ -266,8 +266,7 @@ void SharedWorker::Thaw() {
}
if (!mFrozenEvents.IsEmpty()) {
nsTArray<RefPtr<Event>> events;
mFrozenEvents.SwapElements(events);
nsTArray<RefPtr<Event>> events = std::move(mFrozenEvents);
for (uint32_t index = 0; index < events.Length(); index++) {
RefPtr<Event>& event = events[index];

View File

@ -1333,8 +1333,7 @@ void XMLHttpRequestMainThread::ResumeEventDispatching() {
MOZ_ASSERT(mEventDispatchingSuspended);
mEventDispatchingSuspended = false;
nsTArray<PendingEvent> pendingEvents;
pendingEvents.SwapElements(mPendingEvents);
nsTArray<PendingEvent> pendingEvents = std::move(mPendingEvents);
if (NS_FAILED(CheckCurrentGlobalCorrectness())) {
return;

View File

@ -397,8 +397,8 @@ void XULBroadcastManager::MaybeBroadcast() {
if (length) {
bool oldValue = mHandlingDelayedBroadcasters;
mHandlingDelayedBroadcasters = true;
nsTArray<nsDelayedBroadcastUpdate> delayedBroadcasters;
mDelayedBroadcasters.SwapElements(delayedBroadcasters);
nsTArray<nsDelayedBroadcastUpdate> delayedBroadcasters =
std::move(mDelayedBroadcasters);
for (uint32_t i = 0; i < length; ++i) {
SynchronizeBroadcastListener(delayedBroadcasters[i].mBroadcaster,
delayedBroadcasters[i].mListener,

View File

@ -2758,7 +2758,7 @@ void PermissionManager::CompleteMigrations() {
nsTArray<MigrationEntry> entries;
{
MonitorAutoLock lock(mMonitor);
entries.SwapElements(mMigrationEntries);
entries = std::move(mMigrationEntries);
}
for (const MigrationEntry& entry : entries) {
@ -2786,7 +2786,7 @@ void PermissionManager::CompleteRead() {
nsTArray<ReadEntry> entries;
{
MonitorAutoLock lock(mMonitor);
entries.SwapElements(mReadEntries);
entries = std::move(mReadEntries);
}
for (const ReadEntry& entry : entries) {

View File

@ -127,7 +127,7 @@ void AnimationInfo::TransferMutatedFlagToLayer(Layer* aLayer) {
bool AnimationInfo::ApplyPendingUpdatesForThisTransaction() {
if (mPendingAnimations) {
mPendingAnimations->SwapElements(mAnimations);
mAnimations = std::move(*mPendingAnimations);
mPendingAnimations = nullptr;
return true;
}

View File

@ -285,7 +285,7 @@ void ImageContainer::SetCurrentImageInternal(
}
}
mCurrentImages.SwapElements(newImages);
mCurrentImages = std::move(newImages);
}
void ImageContainer::ClearImagesFromImageBridge() {

View File

@ -199,8 +199,8 @@ class MockContentControllerDelayed : public MockContentController {
// in the queue after this function is called. Only when the return
// value is 0 is the queue guaranteed to be empty.
int RunThroughDelayedTasks() {
nsTArray<std::pair<RefPtr<Runnable>, TimeStamp>> runQueue;
runQueue.SwapElements(mTaskQueue);
nsTArray<std::pair<RefPtr<Runnable>, TimeStamp>> runQueue =
std::move(mTaskQueue);
int numTasks = runQueue.Length();
for (int i = 0; i < numTasks; i++) {
mTime = runQueue[i].second;

View File

@ -251,7 +251,7 @@ bool ImageClientSingle::UpdateImage(ImageContainer* aContainer,
for (auto& b : mBuffers) {
RemoveTexture(b.mTextureClient);
}
mBuffers.SwapElements(newBuffers);
mBuffers = std::move(newBuffers);
return true;
}

View File

@ -188,8 +188,7 @@ void ClientMultiTiledLayerBuffer::Update(const nsIntRegion& newValidRegion,
const size_t oldTileCount = mRetainedTiles.Length();
const size_t newTileCount = newTiles.mSize.width * newTiles.mSize.height;
nsTArray<TileClient> oldRetainedTiles;
mRetainedTiles.SwapElements(oldRetainedTiles);
nsTArray<TileClient> oldRetainedTiles = std::move(mRetainedTiles);
mRetainedTiles.SetLength(newTileCount);
for (size_t oldIndex = 0; oldIndex < oldTileCount; oldIndex++) {

View File

@ -143,8 +143,8 @@ void ShmSegmentsWriter::Flush(nsTArray<RefCountedShmem>& aSmallAllocs,
nsTArray<ipc::Shmem>& aLargeAllocs) {
MOZ_ASSERT(aSmallAllocs.IsEmpty());
MOZ_ASSERT(aLargeAllocs.IsEmpty());
mSmallAllocs.SwapElements(aSmallAllocs);
mLargeAllocs.SwapElements(aLargeAllocs);
aSmallAllocs = std::move(mSmallAllocs);
aLargeAllocs = std::move(mLargeAllocs);
mCursor = 0;
}
@ -457,8 +457,7 @@ void IpcResourceUpdateQueue::Flush(
nsTArray<layers::OpUpdateResource>& aUpdates,
nsTArray<layers::RefCountedShmem>& aSmallAllocs,
nsTArray<ipc::Shmem>& aLargeAllocs) {
aUpdates.Clear();
mUpdates.SwapElements(aUpdates);
aUpdates = std::move(mUpdates);
mWriter.Flush(aSmallAllocs, aLargeAllocs);
}

View File

@ -127,10 +127,8 @@ class FilterPrimitiveDescription final {
*/
struct FilterDescription final {
FilterDescription() = default;
explicit FilterDescription(
nsTArray<FilterPrimitiveDescription>&& aPrimitives) {
mPrimitives.SwapElements(aPrimitives);
}
explicit FilterDescription(nsTArray<FilterPrimitiveDescription>&& aPrimitives)
: mPrimitives(std::move(aPrimitives)) {}
bool operator==(const FilterDescription& aOther) const;
bool operator!=(const FilterDescription& aOther) const {

View File

@ -504,13 +504,12 @@ class nsRegion {
}
nsRegion(const nsRegion& aRegion) { Copy(aRegion); }
nsRegion(nsRegion&& aRegion) {
mBands.SwapElements(aRegion.mBands);
mBounds = aRegion.mBounds;
nsRegion(nsRegion&& aRegion)
: mBands(std::move(aRegion.mBands)), mBounds(aRegion.mBounds) {
aRegion.SetEmpty();
}
nsRegion& operator=(nsRegion&& aRegion) {
mBands.SwapElements(aRegion.mBands);
mBands = std::move(aRegion.mBands);
mBounds = aRegion.mBounds;
aRegion.SetEmpty();
return *this;

View File

@ -83,7 +83,7 @@ class gfxSkipChars {
void KeepChar() { KeepChars(1); }
void TakeFrom(gfxSkipChars* aSkipChars) {
mRanges.SwapElements(aSkipChars->mRanges);
mRanges = std::move(aSkipChars->mRanges);
mCharCount = aSkipChars->mCharCount;
aSkipChars->mCharCount = 0;
}

View File

@ -214,7 +214,7 @@ void gfxUserFontEntry::StoreUserFontData(gfxFontEntry* aFontEntry,
userFontData->mFormat = src.mFormatFlags;
userFontData->mRealName = aOriginalName;
if (aMetadata) {
userFontData->mMetadata.SwapElements(*aMetadata);
userFontData->mMetadata = std::move(*aMetadata);
userFontData->mMetaOrigLen = aMetaOrigLen;
userFontData->mCompression = aCompression;
}

View File

@ -111,7 +111,7 @@ class DecodePoolImpl {
MonitorAutoLock lock(mMonitor);
mShuttingDown = true;
mAvailableThreads = 0;
threads.SwapElements(mThreads);
threads = std::move(mThreads);
mMonitor.NotifyAll();
}

View File

@ -752,10 +752,12 @@ nsresult LoadInfoArgsToLoadInfo(
loadInfoArgs.isInThirdPartyContext(),
loadInfoArgs.isThirdPartyContextToTopWindow(),
loadInfoArgs.isFormSubmission(), loadInfoArgs.sendCSPViolationEvents(),
loadInfoArgs.originAttributes(), redirectChainIncludingInternalRedirects,
redirectChain, std::move(ancestorPrincipals), ancestorBrowsingContextIDs,
loadInfoArgs.corsUnsafeHeaders(), loadInfoArgs.forcePreflight(),
loadInfoArgs.isPreflight(), loadInfoArgs.loadTriggeredFromExternal(),
loadInfoArgs.originAttributes(),
std::move(redirectChainIncludingInternalRedirects),
std::move(redirectChain), std::move(ancestorPrincipals),
ancestorBrowsingContextIDs, loadInfoArgs.corsUnsafeHeaders(),
loadInfoArgs.forcePreflight(), loadInfoArgs.isPreflight(),
loadInfoArgs.loadTriggeredFromExternal(),
loadInfoArgs.serviceWorkerTaintingSynthesized(),
loadInfoArgs.documentHasUserInteracted(),
loadInfoArgs.documentHasLoaded(),

View File

@ -19,8 +19,7 @@ FileDescriptorSetChild::~FileDescriptorSetChild() {
void FileDescriptorSetChild::ForgetFileDescriptors(
nsTArray<FileDescriptor>& aFileDescriptors) {
aFileDescriptors.Clear();
mFileDescriptors.SwapElements(aFileDescriptors);
aFileDescriptors = std::move(mFileDescriptors);
}
mozilla::ipc::IPCResult FileDescriptorSetChild::RecvAddFileDescriptor(

View File

@ -17,8 +17,7 @@ FileDescriptorSetParent::~FileDescriptorSetParent() = default;
void FileDescriptorSetParent::ForgetFileDescriptors(
nsTArray<FileDescriptor>& aFileDescriptors) {
aFileDescriptors.Clear();
mFileDescriptors.SwapElements(aFileDescriptors);
aFileDescriptors = std::move(mFileDescriptors);
}
void FileDescriptorSetParent::ActorDestroy(ActorDestroyReason aWhy) {

View File

@ -626,7 +626,7 @@ struct ParamTraits<FallibleTArray<E>> {
nsTArray<E> temp;
if (!ReadParam(aMsg, aIter, &temp)) return false;
aResult->SwapElements(temp);
*aResult = std::move(temp);
return true;
}

View File

@ -430,7 +430,7 @@ void Logger::Flush() {
nsTArray<nsCString> linesToWrite;
{ // Scope for lock
MutexAutoLock lock(mMutex);
linesToWrite.SwapElements(mEntries);
linesToWrite = std::move(mEntries);
}
for (uint32_t i = 0, len = linesToWrite.Length(); i < len; ++i) {

View File

@ -28,7 +28,7 @@ NS_IMPL_ISUPPORTS(nsXPCTestParams, nsIXPCTestParams)
#define SEQUENCE_METHOD_IMPL(TAKE_OWNERSHIP) \
{ \
_retval.SwapElements(b); \
_retval = std::move(b); \
b = a.Clone(); \
for (uint32_t i = 0; i < b.Length(); ++i) TAKE_OWNERSHIP(b[i]); \
return NS_OK; \

View File

@ -262,8 +262,7 @@ class FrameProperties {
* Remove and destroy all property values for the frame.
*/
void RemoveAll(const nsIFrame* aFrame) {
nsTArray<PropertyValue> toDelete;
toDelete.SwapElements(mProperties);
nsTArray<PropertyValue> toDelete = std::move(mProperties);
for (auto& prop : toDelete) {
prop.DestroyValueFor(aFrame);
}

View File

@ -5818,8 +5818,8 @@ void PresShell::RebuildApproximateFrameVisibilityDisplayList(
// Remove the entries of the mApproximatelyVisibleFrames hashtable and put
// them in oldApproxVisibleFrames.
VisibleFrames oldApproximatelyVisibleFrames;
mApproximatelyVisibleFrames.SwapElements(oldApproximatelyVisibleFrames);
VisibleFrames oldApproximatelyVisibleFrames =
std::move(mApproximatelyVisibleFrames);
MarkFramesInListApproximatelyVisible(aList);
@ -5970,8 +5970,8 @@ void PresShell::RebuildApproximateFrameVisibility(
// Remove the entries of the mApproximatelyVisibleFrames hashtable and put
// them in oldApproximatelyVisibleFrames.
VisibleFrames oldApproximatelyVisibleFrames;
mApproximatelyVisibleFrames.SwapElements(oldApproximatelyVisibleFrames);
VisibleFrames oldApproximatelyVisibleFrames =
std::move(mApproximatelyVisibleFrames);
nsRect vis(nsPoint(0, 0), rootFrame->GetSize());
if (aRect) {

View File

@ -1958,16 +1958,16 @@ void nsPresContext::ClearNotifySubDocInvalidationData(
class DelayedFireDOMPaintEvent : public Runnable {
public:
DelayedFireDOMPaintEvent(
nsPresContext* aPresContext, nsTArray<nsRect>* aList,
nsPresContext* aPresContext, nsTArray<nsRect>&& aList,
TransactionId aTransactionId,
const mozilla::TimeStamp& aTimeStamp = mozilla::TimeStamp())
: mozilla::Runnable("DelayedFireDOMPaintEvent"),
mPresContext(aPresContext),
mTransactionId(aTransactionId),
mTimeStamp(aTimeStamp) {
mTimeStamp(aTimeStamp),
mList(std::move(aList)) {
MOZ_ASSERT(mPresContext->GetContainerWeak(),
"DOMPaintEvent requested for a detached pres context");
mList.SwapElements(*aList);
}
NS_IMETHOD Run() override {
// The pres context might have been detached during the delay -
@ -2010,8 +2010,8 @@ void nsPresContext::NotifyRevokingDidPaint(TransactionId aTransactionId) {
// If this is the only transaction, then we can send it immediately.
if (mTransactions.Length() == 1) {
nsCOMPtr<nsIRunnable> ev = new DelayedFireDOMPaintEvent(
this, &transaction->mInvalidations, transaction->mTransactionId,
mozilla::TimeStamp());
this, std::move(transaction->mInvalidations),
transaction->mTransactionId, mozilla::TimeStamp());
nsContentUtils::AddScriptRunner(ev);
mTransactions.RemoveElementAt(0);
} else {
@ -2059,7 +2059,7 @@ void nsPresContext::NotifyDidPaintForSubtree(
if (mTransactions[i].mTransactionId <= aTransactionId) {
if (!mTransactions[i].mInvalidations.IsEmpty()) {
nsCOMPtr<nsIRunnable> ev = new DelayedFireDOMPaintEvent(
this, &mTransactions[i].mInvalidations,
this, std::move(mTransactions[i].mInvalidations),
mTransactions[i].mTransactionId, aTimeStamp);
nsContentUtils::AddScriptRunner(ev);
sent = true;
@ -2070,7 +2070,7 @@ void nsPresContext::NotifyDidPaintForSubtree(
// we should fire a MozAfterPaint immediately.
if (sent && mTransactions[i].mIsWaitingForPreviousTransaction) {
nsCOMPtr<nsIRunnable> ev = new DelayedFireDOMPaintEvent(
this, &mTransactions[i].mInvalidations,
this, std::move(mTransactions[i].mInvalidations),
mTransactions[i].mTransactionId, aTimeStamp);
nsContentUtils::AddScriptRunner(ev);
sent = true;
@ -2083,8 +2083,8 @@ void nsPresContext::NotifyDidPaintForSubtree(
if (!sent) {
nsTArray<nsRect> dummy;
nsCOMPtr<nsIRunnable> ev =
new DelayedFireDOMPaintEvent(this, &dummy, aTransactionId, aTimeStamp);
nsCOMPtr<nsIRunnable> ev = new DelayedFireDOMPaintEvent(
this, std::move(dummy), aTransactionId, aTimeStamp);
nsContentUtils::AddScriptRunner(ev);
}
@ -2684,8 +2684,8 @@ static void SortConfigurations(
return;
}
nsTArray<nsIWidget::Configuration> pluginsToMove;
pluginsToMove.SwapElements(*aConfigurations);
nsTArray<nsIWidget::Configuration> pluginsToMove =
std::move(*aConfigurations);
// Our algorithm is quite naive. At each step we try to identify
// a window that can be moved to its new location that won't overlap
@ -2807,8 +2807,7 @@ void nsRootPresContext::AddWillPaintObserver(nsIRunnable* aRunnable) {
*/
void nsRootPresContext::FlushWillPaintObservers() {
mWillPaintFallbackEvent = nullptr;
nsTArray<nsCOMPtr<nsIRunnable>> observers;
observers.SwapElements(mWillPaintObservers);
nsTArray<nsCOMPtr<nsIRunnable>> observers = std::move(mWillPaintObservers);
for (uint32_t i = 0; i < observers.Length(); ++i) {
observers[i]->Run();
}

View File

@ -1279,8 +1279,8 @@ void nsRefreshDriver::DispatchVisualViewportResizeEvents() {
// We're taking a hint from scroll events and only dispatch the current set
// of queued resize events. If additional events are posted in response to
// the current events being dispatched, we'll dispatch them on the next tick.
VisualViewportResizeEventArray events;
events.SwapElements(mVisualViewportResizeEvents);
VisualViewportResizeEventArray events =
std::move(mVisualViewportResizeEvents);
for (auto& event : events) {
event->Run();
}
@ -1301,8 +1301,7 @@ void nsRefreshDriver::DispatchScrollEvents() {
// However, dispatching a scroll event can potentially cause more scroll
// events to be posted, so we move the initial set into a temporary array
// first. (Newly posted scroll events will be dispatched on the next tick.)
ScrollEventArray events;
events.SwapElements(mScrollEvents);
ScrollEventArray events = std::move(mScrollEvents);
for (auto& event : events) {
event->Run();
}
@ -1319,8 +1318,8 @@ void nsRefreshDriver::DispatchVisualViewportScrollEvents() {
// However, dispatching a scroll event can potentially cause more scroll
// events to be posted, so we move the initial set into a temporary array
// first. (Newly posted scroll events will be dispatched on the next tick.)
VisualViewportScrollEventArray events;
events.SwapElements(mVisualViewportScrollEvents);
VisualViewportScrollEventArray events =
std::move(mVisualViewportScrollEvents);
for (auto& event : events) {
event->Run();
}
@ -2015,8 +2014,7 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {
nsLayoutUtils::UpdateDisplayPortMarginsFromPendingMessages();
}
AutoTArray<nsCOMPtr<nsIRunnable>, 16> earlyRunners;
earlyRunners.SwapElements(mEarlyRunners);
AutoTArray<nsCOMPtr<nsIRunnable>, 16> earlyRunners = std::move(mEarlyRunners);
for (auto& runner : earlyRunners) {
runner->Run();
}

View File

@ -8932,15 +8932,13 @@ void nsGridContainerFrame::Reflow(nsPresContext* aPresContext,
sharedGridData = new SharedGridData;
SetProperty(SharedGridData::Prop(), sharedGridData);
}
sharedGridData->mCols.mSizes.Clear();
sharedGridData->mCols.mSizes.SwapElements(gridReflowInput.mCols.mSizes);
sharedGridData->mCols.mSizes = std::move(gridReflowInput.mCols.mSizes);
sharedGridData->mCols.mContentBoxSize =
gridReflowInput.mCols.mContentBoxSize;
sharedGridData->mCols.mBaselineSubtreeAlign =
gridReflowInput.mCols.mBaselineSubtreeAlign;
sharedGridData->mCols.mIsMasonry = gridReflowInput.mCols.mIsMasonry;
sharedGridData->mRows.mSizes.Clear();
sharedGridData->mRows.mSizes.SwapElements(gridReflowInput.mRows.mSizes);
sharedGridData->mRows.mSizes = std::move(gridReflowInput.mRows.mSizes);
// Save the original row grid sizes and gaps so we can restore them later
// in GridReflowInput::Initialize for the continuations.
auto& origRowData = sharedGridData->mOriginalRowData;
@ -8957,10 +8955,8 @@ void nsGridContainerFrame::Reflow(nsPresContext* aPresContext,
sharedGridData->mRows.mBaselineSubtreeAlign =
gridReflowInput.mRows.mBaselineSubtreeAlign;
sharedGridData->mRows.mIsMasonry = gridReflowInput.mRows.mIsMasonry;
sharedGridData->mGridItems.Clear();
sharedGridData->mGridItems.SwapElements(gridReflowInput.mGridItems);
sharedGridData->mAbsPosItems.Clear();
sharedGridData->mAbsPosItems.SwapElements(gridReflowInput.mAbsPosItems);
sharedGridData->mGridItems = std::move(gridReflowInput.mGridItems);
sharedGridData->mAbsPosItems = std::move(gridReflowInput.mAbsPosItems);
sharedGridData->mGenerateComputedGridInfo = ShouldGenerateComputedInfo();
} else if (sharedGridData && !GetNextInFlow()) {

View File

@ -134,8 +134,8 @@ void nsMathMLmunderoverFrame::ReflowCallbackCanceled() {
void nsMathMLmunderoverFrame::SetPendingPostReflowIncrementScriptLevel() {
MOZ_ASSERT(!mPostReflowIncrementScriptLevelCommands.IsEmpty());
nsTArray<SetIncrementScriptLevelCommand> commands;
commands.SwapElements(mPostReflowIncrementScriptLevelCommands);
nsTArray<SetIncrementScriptLevelCommand> commands =
std::move(mPostReflowIncrementScriptLevelCommands);
for (const auto& command : commands) {
nsIFrame* child = PrincipalChildList().FrameAt(command.mChildIndex);

View File

@ -1886,7 +1886,7 @@ struct MaskLayerUserData : public LayerUserData {
mScaleY = aOther.mScaleY;
mOffset = aOther.mOffset;
mAppUnitsPerDevPixel = aOther.mAppUnitsPerDevPixel;
mRoundedClipRects.SwapElements(aOther.mRoundedClipRects);
mRoundedClipRects = std::move(aOther.mRoundedClipRects);
}
bool operator==(const MaskLayerUserData& aOther) const {

View File

@ -664,8 +664,7 @@ bool FontFaceSet::UpdateRules(const nsTArray<nsFontFaceRuleContainer>& aRules) {
// re-download resources in the (common) case where at least some of the
// same rules are still present.
nsTArray<FontFaceRecord> oldRecords;
mRuleFaces.SwapElements(oldRecords);
nsTArray<FontFaceRecord> oldRecords = std::move(mRuleFaces);
// Remove faces from the font family records; we need to re-insert them
// because we might end up with faces in a different order even if they're
@ -1645,7 +1644,7 @@ void FontFaceSet::DispatchLoadingFinishedEvent(
FontFaceSetLoadEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mFontfaces.SwapElements(aFontFaces);
init.mFontfaces = std::move(aFontFaces);
RefPtr<FontFaceSetLoadEvent> event =
FontFaceSetLoadEvent::Constructor(this, aType, init);
(new AsyncEventDispatcher(this, event))->PostDOMEvent();

View File

@ -1187,8 +1187,7 @@ void ServoStyleSet::RunPostTraversalTasks() {
return;
}
nsTArray<PostTraversalTask> tasks;
tasks.SwapElements(mPostTraversalTasks);
nsTArray<PostTraversalTask> tasks = std::move(mPostTraversalTasks);
for (auto& task : tasks) {
task.Run();

View File

@ -36,12 +36,8 @@ class nsStyleAutoArray {
return !(*this == aOther);
}
nsStyleAutoArray& operator=(nsStyleAutoArray&& aOther) {
mFirstElement = aOther.mFirstElement;
mOtherElements.SwapElements(aOther.mOtherElements);
return *this;
}
nsStyleAutoArray(nsStyleAutoArray&& aOther) = default;
nsStyleAutoArray& operator=(nsStyleAutoArray&& aOther) = default;
size_t Length() const { return mOtherElements.Length() + 1; }
const T& operator[](size_t aIndex) const {

View File

@ -179,7 +179,7 @@ class FilterInstance {
const FilterDescription& ExtractDescriptionAndAdditionalImages(
nsTArray<RefPtr<SourceSurface>>& aOutAdditionalImages) {
mInputImages.SwapElements(aOutAdditionalImages);
aOutAdditionalImages = std::move(mInputImages);
return mFilterDescription;
}

View File

@ -1953,8 +1953,7 @@ void nsCellMap::RebuildConsideringRows(
NS_ASSERTION(!!aMap.mBCInfo == mIsBC, "BC state mismatch");
// copy the old cell map into a new array
uint32_t numOrigRows = mRows.Length();
nsTArray<CellDataArray> origRows;
mRows.SwapElements(origRows);
nsTArray<CellDataArray> origRows = std::move(mRows);
int32_t rowNumberChange;
if (aRowsToInsert) {
@ -2053,8 +2052,7 @@ void nsCellMap::RebuildConsideringCells(
NS_ASSERTION(!!aMap.mBCInfo == mIsBC, "BC state mismatch");
// copy the old cell map into a new array
int32_t numOrigRows = mRows.Length();
nsTArray<CellDataArray> origRows;
mRows.SwapElements(origRows);
nsTArray<CellDataArray> origRows = std::move(mRows);
int32_t numNewCells = (aCellFrames) ? aCellFrames->Length() : 0;

Some files were not shown because too many files have changed in this diff Show More