Use std::move() for rvalues in SerialMap and SerialQueue

Change-Id: Iddaf8227cb76b823107997a740eb7563268ff859
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116925
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Peng Huang 2023-01-13 18:30:21 +00:00 committed by Dawn LUCI CQ
parent dd54f74de1
commit f58ef99a15
2 changed files with 5 additions and 4 deletions

View File

@ -16,6 +16,7 @@
#define SRC_DAWN_COMMON_SERIALMAP_H_
#include <map>
#include <utility>
#include <vector>
#include "dawn/common/SerialStorage.h"
@ -54,7 +55,7 @@ void SerialMap<Serial, Value>::Enqueue(const Value& value, Serial serial) {
template <typename Serial, typename Value>
void SerialMap<Serial, Value>::Enqueue(Value&& value, Serial serial) {
this->mStorage[serial].emplace_back(value);
this->mStorage[serial].emplace_back(std::move(value));
}
template <typename Serial, typename Value>
@ -68,8 +69,8 @@ void SerialMap<Serial, Value>::Enqueue(const std::vector<Value>& values, Serial
template <typename Serial, typename Value>
void SerialMap<Serial, Value>::Enqueue(std::vector<Value>&& values, Serial serial) {
DAWN_ASSERT(values.size() > 0);
for (const Value& value : values) {
Enqueue(value, serial);
for (Value& value : values) {
Enqueue(std::move(value), serial);
}
}

View File

@ -80,7 +80,7 @@ template <typename Serial, typename Value>
void SerialQueue<Serial, Value>::Enqueue(std::vector<Value>&& values, Serial serial) {
DAWN_ASSERT(values.size() > 0);
DAWN_ASSERT(this->Empty() || this->mStorage.back().first <= serial);
this->mStorage.emplace_back(serial, values);
this->mStorage.emplace_back(serial, std::move(values));
}
#endif // SRC_DAWN_COMMON_SERIALQUEUE_H_