Use reference when copying strings into mapbuffer

Summary:
This method can produce unnecessary copy of the string, replacing it with reference to optimize.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33607765

fbshipit-source-id: e04eddffec063c0c8e173bfdf690e7b8e1050525
This commit is contained in:
Andrei Shikov authored and Facebook GitHub Bot committed 2022-01-16 23:07:40 -08:00
1 parent 6b42bcc1f4
commit ea712f825a
2 files changed
+2 -2

No files matched your search

@@ -125,7 +125,7 @@ void MapBufferBuilder::ensureDynamicDataSpace(int32_t size) {
}
}
void MapBufferBuilder::putString(Key key, std::string value) {
void MapBufferBuilder::putString(Key key, std::string const &value) {
int32_t strLength = static_cast<int32_t>(value.length());
const char *cstring = getCstring(&value);
@@ -82,7 +82,7 @@ class MapBufferBuilder {
void putNull(Key key);
void putString(Key key, std::string value);
void putString(Key key, std::string const &value);
void putMapBuffer(Key key, MapBuffer &map);