Avoid a guarded local static for the empty key view
CI / build-and-check (push) Successful in 8m13s

This commit is contained in:
andrew committed 2026-11-18 15:24:47 -05:00
1 parent bf149c26b5
commit b665b2dc6f
1 file changed
+3 -5
+3 -5
View File
@@ -169,11 +169,9 @@ inline OptKey optMax(const std::optional<A>& a, const std::optional<B>& b) {
inline OptKey topKey() { return std::nullopt; }
inline OptKey bottomKey() { return OptKey{Key{}}; }
// A view of a static empty string, so empty views always have a valid pointer.
inline KeyView emptyKeyView() {
static const Key empty;
return KeyView(empty);
}
// A view of the empty string literal, so empty views always have a valid
// pointer. Unlike a function-local static, this needs no guard variable.
inline KeyView emptyKeyView() { return KeyView("", 0); }
inline OptKeyView bottomKeyView() { return OptKeyView{emptyKeyView()}; }
inline bool isTop(OptKeyView k) { return !k.has_value(); }