Avoid another string construction

This commit is contained in:
Erica Fischer
2024-01-25 14:30:56 -08:00
parent 5b457dfe68
commit d0f43bf582
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -159,7 +159,11 @@ bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
case 1: /* string */ case 1: /* string */
value.type = mvt_string; value.type = mvt_string;
value.s = string_pool; value.s = string_pool;
value.set_string_value(value_reader.get_string()); {
auto v = value_reader.get_view();
std::string_view sv(v.data(), v.size());
value.set_string_value(sv);
}
break; break;
case 2: /* float */ case 2: /* float */
+1 -1
View File
@@ -105,7 +105,7 @@ struct mvt_value {
return s->c_str() + numeric_value.string_value.off; return s->c_str() + numeric_value.string_value.off;
} }
void set_string_value(const std::string &val) { void set_string_value(const std::string_view &val) {
if (s == nullptr) { if (s == nullptr) {
s = std::make_shared<std::string>(); s = std::make_shared<std::string>();
} }