Several changes to reduce unnecessary moves/copies
This commit is contained in:
parent
3b0f37a5d5
commit
667b224fc8
|
@ -219,8 +219,9 @@ struct VersionedMutations {
|
|||
*/
|
||||
struct DecodeProgress {
|
||||
DecodeProgress() = default;
|
||||
DecodeProgress(const LogFile& file, std::vector<std::tuple<Arena, Version, int32_t, StringRef>> values)
|
||||
: file(file), keyValues(values) {}
|
||||
template <class U>
|
||||
DecodeProgress(const LogFile& file, U &&values)
|
||||
: file(file), keyValues(std::forward<U>(values)) {}
|
||||
|
||||
// If there are no more mutations to pull from the file.
|
||||
// However, we could have unfinished version in the buffer when EOF is true,
|
||||
|
@ -228,7 +229,7 @@ struct DecodeProgress {
|
|||
// should call getUnfinishedBuffer() to get these left data.
|
||||
bool finished() { return (eof && keyValues.empty()) || (leftover && !keyValues.empty()); }
|
||||
|
||||
std::vector<std::tuple<Arena, Version, int32_t, StringRef>>&& getUnfinishedBuffer() { return std::move(keyValues); }
|
||||
std::vector<std::tuple<Arena, Version, int32_t, StringRef>>&& getUnfinishedBuffer() && { return std::move(keyValues); }
|
||||
|
||||
// Returns all mutations of the next version in a batch.
|
||||
Future<VersionedMutations> getNextBatch() { return getNextBatchImpl(this); }
|
||||
|
@ -448,7 +449,7 @@ ACTOR Future<Void> decode_logs(DecodeParams params) {
|
|||
for (; i < logs.size(); i++) {
|
||||
if (logs[i].fileSize == 0) continue;
|
||||
|
||||
state DecodeProgress progress(logs[i], left);
|
||||
state DecodeProgress progress(logs[i], std::move(left));
|
||||
wait(progress.openFile(container));
|
||||
while (!progress.finished()) {
|
||||
VersionedMutations vms = wait(progress.getNextBatch());
|
||||
|
@ -456,7 +457,7 @@ ACTOR Future<Void> decode_logs(DecodeParams params) {
|
|||
std::cout << vms.version << " " << m.toString() << "\n";
|
||||
}
|
||||
}
|
||||
left = progress.getUnfinishedBuffer();
|
||||
left = std::move(progress).getUnfinishedBuffer();
|
||||
if (!left.empty()) {
|
||||
TraceEvent("UnfinishedFile").detail("File", logs[i].fileName).detail("Q", left.size());
|
||||
}
|
||||
|
|
|
@ -769,7 +769,7 @@ Reference<LocationInfo> DatabaseContext::setCachedLocation( const KeyRangeRef& k
|
|||
locationCache.insert( KeyRangeRef(begin, end), Reference<LocationInfo>() );
|
||||
}
|
||||
locationCache.insert( keys, loc );
|
||||
return std::move(loc);
|
||||
return loc;
|
||||
}
|
||||
|
||||
void DatabaseContext::invalidateCache( const KeyRef& key, bool isBackward ) {
|
||||
|
@ -2480,7 +2480,7 @@ ACTOR Future< Key > getKeyAndConflictRange(
|
|||
conflictRange.send( std::make_pair( rep, k.orEqual ? keyAfter( k.getKey() ) : Key(k.getKey(), k.arena()) ) );
|
||||
else
|
||||
conflictRange.send( std::make_pair( k.orEqual ? keyAfter( k.getKey() ) : Key(k.getKey(), k.arena()), keyAfter( rep ) ) );
|
||||
return std::move(rep);
|
||||
return rep;
|
||||
} catch( Error&e ) {
|
||||
conflictRange.send(std::make_pair(Key(), Key()));
|
||||
throw;
|
||||
|
|
Loading…
Reference in New Issue