Skip to content

Commit

Permalink
CCBC-1525: remove stringstream in collection_qualifier
Browse files Browse the repository at this point in the history
Constructing a stringstream object every time collection_qualifier is constructed is very expensive. This commit changes the collection_qualifier constructor to use plain string appending instead of stringstream.

Change-Id: I155b6d6966adcfc1c0b41a6e649faae956fd9f9a
Reviewed-on: https://review.couchbase.org/c/libcouchbase/+/167383
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
  • Loading branch information
d-nagy authored and avsej committed Dec 29, 2021
1 parent ccbaadf commit 45dcd8f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/capi/collection_qualifier.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <cstddef>
#include <cstdint>
#include <string>
#include <sstream>
#include <stdexcept>

namespace lcb
Expand All @@ -48,11 +47,10 @@ struct collection_qualifier {
if (collection_name != nullptr && collection_name_len > 0) {
collection_.assign(collection_name, collection_name_len);
}
std::stringstream ss;
ss << (scope_.empty() ? "_default" : scope_);
ss << '.';
ss << (collection_.empty() ? "_default" : collection_);
spec_ = ss.str();

spec_ = (scope_.empty() ? "_default" : scope_) +
'.' +
(collection_.empty() ? "_default" : collection_);
}

const std::string &scope() const
Expand Down

0 comments on commit 45dcd8f

Please sign in to comment.