From 8f7a1d3c2c59b72d193e5eeed065ebd8f13d4ecc Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 30 Apr 2023 14:04:28 +0200 Subject: Core/Misc: Delay creating std::string objects for locale data after size validation --- src/server/game/Texts/CreatureTextMgr.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/server/game/Texts') diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index b86c14d28b1..46976e70d96 100644 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -154,17 +154,17 @@ void CreatureTextMgr::LoadCreatureTextLocales() { Field* fields = result->Fetch(); - uint32 creatureId = fields[0].GetUInt32(); - uint32 groupId = fields[1].GetUInt8(); - uint32 id = fields[2].GetUInt8(); - std::string localeName = fields[3].GetString(); + uint32 creatureId = fields[0].GetUInt32(); + uint32 groupId = fields[1].GetUInt8(); + uint32 id = fields[2].GetUInt8(); + std::string_view localeName = fields[3].GetStringView(); LocaleConstant locale = GetLocaleByName(localeName); if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; CreatureTextLocale& data = mLocaleTextMap[CreatureTextId(creatureId, groupId, id)]; - ObjectMgr::AddLocaleString(fields[4].GetString(), locale, data.Text); + ObjectMgr::AddLocaleString(fields[4].GetStringView(), locale, data.Text); } while (result->NextRow()); TC_LOG_INFO("server.loading", ">> Loaded {} creature localized texts in {} ms", uint32(mLocaleTextMap.size()), GetMSTimeDiffToNow(oldMSTime)); -- cgit v1.2.3