summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-01-09 22:30:59 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2017-01-11 10:19:19 +0000
commit90d2dced09abe94057f0332e0589ae88c81d2801 (patch)
tree89d8be53c3adbf8d98d09010143341a3005db077 /storage
parent6f67683319c6aeaf32b1341e5b11736106722d5c (diff)
Use emplace back and std::move to reduce expensive copying of shared pointers.
Diffstat (limited to 'storage')
-rw-r--r--storage/src/vespa/storage/common/messagebucketid.cpp1
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.cpp16
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.h5
3 files changed, 15 insertions, 7 deletions
diff --git a/storage/src/vespa/storage/common/messagebucketid.cpp b/storage/src/vespa/storage/common/messagebucketid.cpp
index 2135cbcd9b6..ae71e47005f 100644
--- a/storage/src/vespa/storage/common/messagebucketid.cpp
+++ b/storage/src/vespa/storage/common/messagebucketid.cpp
@@ -3,7 +3,6 @@
#include "messagebucketid.h"
#include "statusmessages.h"
#include "bucketmessages.h"
-#include <vespa/storageapi/messageapi/storagemessage.h>
#include <vespa/storageapi/message/bucket.h>
#include <vespa/storageapi/message/bucketsplitting.h>
#include <vespa/storageapi/message/multioperation.h>
diff --git a/storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.cpp b/storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.cpp
index 1d54992bfad..80cbc99aa51 100644
--- a/storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.cpp
+++ b/storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.cpp
@@ -255,8 +255,7 @@ FileStorHandlerImpl::schedule(const std::shared_ptr<api::StorageMessage>& msg,
"FileStorHandler: Operation added to disk %d's queue with "
"priority %u", disk, msg->getPriority()));
- t.queue.push_back(MessageEntry(msg,
- getStorageMessageBucketId(*msg)));
+ t.queue.emplace_back(msg, getStorageMessageBucketId(*msg));
LOG(spam, "Queued operation %s with priority %u.",
msg->getType().toString().c_str(),
@@ -1053,7 +1052,7 @@ FileStorHandlerImpl::remapQueueNoLock(
for (BucketIdx::iterator i = range.first; i != range.second; ++i) {
assert(i->_bucketId == source.bid);
- entriesFound.push_back(*i);
+ entriesFound.push_back(std::move(*i));
}
// Remove them
@@ -1094,7 +1093,7 @@ FileStorHandlerImpl::remapQueueNoLock(
} else {
entry._bucketId = bid;
// Move to correct disk queue if needed
- _diskInfo[targetDisk].queue.push_back(entry);
+ _diskInfo[targetDisk].queue.emplace_back(std::move(entry));
}
}
@@ -1209,6 +1208,7 @@ FileStorHandlerImpl::MessageEntry::MessageEntry(const std::shared_ptr<api::Stora
_priority(cmd->getPriority())
{ }
+
FileStorHandlerImpl::MessageEntry::MessageEntry(const MessageEntry& entry)
: _command(entry._command),
_timer(entry._timer),
@@ -1216,6 +1216,14 @@ FileStorHandlerImpl::MessageEntry::MessageEntry(const MessageEntry& entry)
_priority(entry._priority)
{ }
+
+FileStorHandlerImpl::MessageEntry::MessageEntry(MessageEntry && entry)
+ : _command(std::move(entry._command)),
+ _timer(entry._timer),
+ _bucketId(entry._bucketId),
+ _priority(entry._priority)
+{ }
+
FileStorHandlerImpl::MessageEntry::~MessageEntry() { }
FileStorHandlerImpl::Disk::Disk()
diff --git a/storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.h b/storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.h
index da3abd17cdf..90b4ea6ed37 100644
--- a/storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.h
+++ b/storage/src/vespa/storage/persistence/filestorage/filestorhandlerimpl.h
@@ -15,11 +15,11 @@
#pragma once
+#include "filestorhandler.h"
+#include "mergestatus.h"
#include <vespa/document/bucket/bucketid.h>
#include <vespa/metrics/metrics.h>
#include <vespa/storage/common/servicelayercomponent.h>
-#include <vespa/storage/persistence/filestorage/filestorhandler.h>
-#include <vespa/storage/persistence/filestorage/mergestatus.h>
#include <vespa/storageframework/storageframework.h>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/identity.hpp>
@@ -51,6 +51,7 @@ public:
uint8_t _priority;
MessageEntry(const std::shared_ptr<api::StorageMessage>& cmd, const document::BucketId& bId);
+ MessageEntry(MessageEntry &&);
MessageEntry(const MessageEntry &);
MessageEntry & operator = (const MessageEntry &) = delete;
~MessageEntry();