Skip to content

Commit aa7d4d2

Browse files
authored
make_qualified_base_name: qbn string view (#419)
* make_qualified_base_name: use std::string_view The function takes const std::string& but its callers in util.cc:1289, 1332, 1420 pass `(const std::string ext_name, const char *)` — the const char* is silently wrapped in a temporary std::string. Switching to std::string_view lets all current callers pass through unchanged (std::string and const char* both convert implicitly) while removing those hidden allocations. Closes #416. Surfaced in #257 review thread; #408 deferred this. * make_qualified_base_name: reserve+append, no temporaries Per maintainer review: the std::string_view conversion in PR #419 left the body constructing two std::string temporaries plus operator+ intermediates — 2-4 allocations to do what should be 0-1. Switch to reserve + append/push_back for a single allocation when the result exceeds SSO.
1 parent 3b8b394 commit aa7d4d2

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

villagesql/schema/systable/helpers.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,14 @@ std::string normalize_extension_name(const std::string &name);
5252
std::string normalize_type_name(const std::string &name);
5353

5454
// Build a qualified base name string "extension_name.type_name".
55-
inline std::string make_qualified_base_name(const std::string &extension_name,
56-
const std::string &type_name) {
57-
return extension_name + "." + type_name;
55+
inline std::string make_qualified_base_name(std::string_view extension_name,
56+
std::string_view type_name) {
57+
std::string result;
58+
result.reserve(extension_name.size() + 1 + type_name.size());
59+
result.append(extension_name);
60+
result.push_back('.');
61+
result.append(type_name);
62+
return result;
5863
}
5964

6065
// Returns true if name is a qualified custom type name (contains a dot),

0 commit comments

Comments
 (0)