diff --git a/src/strgen/strgen.h b/src/strgen/strgen.h index e146b4612e..88b64c9469 100644 --- a/src/strgen/strgen.h +++ b/src/strgen/strgen.h @@ -39,16 +39,16 @@ struct LangString { /** Information about the currently known strings. */ struct StringData { - std::vector> strings; ///< List of all known strings. - std::unordered_map name_to_string; ///< Lookup table for the strings. + std::vector> strings; ///< List of all known strings. + std::unordered_map> name_to_string; ///< Lookup table for the strings. size_t tabs; ///< The number of 'tabs' of strings. size_t max_strings; ///< The maximum number of strings. size_t next_string_id;///< The next string ID to allocate. StringData(size_t tabs); void FreeTranslation(); - void Add(std::unique_ptr ls); - LangString *Find(const std::string_view s); + void Add(std::shared_ptr ls); + LangString *Find(const std::string &s); uint VersionHashStr(uint hash, const char *s) const; uint Version() const; uint CountInUse(uint tab) const; diff --git a/src/strgen/strgen_base.cpp b/src/strgen/strgen_base.cpp index d30c973f6a..b369415834 100644 --- a/src/strgen/strgen_base.cpp +++ b/src/strgen/strgen_base.cpp @@ -85,10 +85,10 @@ void StringData::FreeTranslation() * @param s The name of the string. * @param ls The string to add. */ -void StringData::Add(std::unique_ptr ls) +void StringData::Add(std::shared_ptr ls) { - this->name_to_string[ls->name] = ls.get(); - this->strings[ls->index].swap(ls); + this->name_to_string[ls->name] = ls; + this->strings[ls->index] = std::move(ls); } /** @@ -96,12 +96,12 @@ void StringData::Add(std::unique_ptr ls) * @param s The string name to search on. * @return The LangString or nullptr if it is not known. */ -LangString *StringData::Find(const std::string_view s) +LangString *StringData::Find(const std::string &s) { auto it = this->name_to_string.find(s); if (it == this->name_to_string.end()) return nullptr; - return it->second; + return it->second.get(); } /**