From 83d3ce9f1fc2142e873558c07b71693baee57763 Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Tue, 19 Dec 2023 22:41:40 +0100 Subject: [PATCH] Use copies of strings for the cache instead of string_views. Apparently my assumption was wrong. --- source/mijin/types/name.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/source/mijin/types/name.cpp b/source/mijin/types/name.cpp index 15562bc..61f5e71 100644 --- a/source/mijin/types/name.cpp +++ b/source/mijin/types/name.cpp @@ -8,9 +8,6 @@ #include #include -// note: the implementation assumes that std::vector moves the strings on resize and that strings don't reallocate when moved -// while that should be the case for any sane STL implementation it may cause dangling pointers if it's not - namespace mijin { @@ -52,9 +49,9 @@ static std::shared_mutex& getGlobalNamesMutex() return mutex; } -static std::unordered_map& getLocalNameCache() +static std::unordered_map& getLocalNameCache() { - static std::unordered_map cache; + static std::unordered_map cache; return cache; }