diff --git a/apps/launcher/advancedpage.cpp b/apps/launcher/advancedpage.cpp index 73aec4cdae..0f28c28b70 100644 --- a/apps/launcher/advancedpage.cpp +++ b/apps/launcher/advancedpage.cpp @@ -164,7 +164,7 @@ bool Launcher::AdvancedPage::loadSettings() // Audio { - std::string selectedAudioDevice = Settings::Manager::getString("device", "Sound"); + const std::string& selectedAudioDevice = Settings::Manager::getString("device", "Sound"); if (selectedAudioDevice.empty() == false) { int audioDeviceIndex = audioDeviceSelectorComboBox->findData(QString::fromStdString(selectedAudioDevice)); @@ -178,7 +178,7 @@ bool Launcher::AdvancedPage::loadSettings() { enableHRTFComboBox->setCurrentIndex(hrtfEnabledIndex + 1); } - std::string selectedHRTFProfile = Settings::Manager::getString("hrtf", "Sound"); + const std::string& selectedHRTFProfile = Settings::Manager::getString("hrtf", "Sound"); if (selectedHRTFProfile.empty() == false) { int hrtfProfileIndex = hrtfProfileSelectorComboBox->findData(QString::fromStdString(selectedHRTFProfile)); @@ -323,7 +323,7 @@ void Launcher::AdvancedPage::saveSettings() // Audio { int audioDeviceIndex = audioDeviceSelectorComboBox->currentIndex(); - std::string prevAudioDevice = Settings::Manager::getString("device", "Sound"); + const std::string& prevAudioDevice = Settings::Manager::getString("device", "Sound"); if (audioDeviceIndex != 0) { const std::string& newAudioDevice = audioDeviceSelectorComboBox->currentText().toUtf8().constData(); @@ -340,7 +340,7 @@ void Launcher::AdvancedPage::saveSettings() Settings::Manager::setInt("hrtf enable", "Sound", hrtfEnabledIndex); } int selectedHRTFProfileIndex = hrtfProfileSelectorComboBox->currentIndex(); - std::string prevHRTFProfile = Settings::Manager::getString("hrtf", "Sound"); + const std::string& prevHRTFProfile = Settings::Manager::getString("hrtf", "Sound"); if (selectedHRTFProfileIndex != 0) { const std::string& newHRTFProfile = hrtfProfileSelectorComboBox->currentText().toUtf8().constData(); diff --git a/apps/opencs/model/prefs/modifiersetting.cpp b/apps/opencs/model/prefs/modifiersetting.cpp index aa8b651547..1e4d29f1b6 100644 --- a/apps/opencs/model/prefs/modifiersetting.cpp +++ b/apps/opencs/model/prefs/modifiersetting.cpp @@ -49,7 +49,7 @@ namespace CSMPrefs { if (mButton) { - std::string shortcut = Settings::Manager::getString(getKey(), getParent()->getKey()); + const std::string& shortcut = Settings::Manager::getString(getKey(), getParent()->getKey()); int modifier; State::get().getShortcutManager().convertFromString(shortcut, modifier); diff --git a/apps/opencs/model/prefs/shortcutsetting.cpp b/apps/opencs/model/prefs/shortcutsetting.cpp index 0d5f9c039a..44260b8cb0 100644 --- a/apps/opencs/model/prefs/shortcutsetting.cpp +++ b/apps/opencs/model/prefs/shortcutsetting.cpp @@ -55,7 +55,7 @@ namespace CSMPrefs { if (mButton) { - std::string shortcut = Settings::Manager::getString(getKey(), getParent()->getKey()); + const std::string& shortcut = Settings::Manager::getString(getKey(), getParent()->getKey()); QKeySequence sequence; State::get().getShortcutManager().convertFromString(shortcut, sequence); diff --git a/apps/opencs/model/world/columns.cpp b/apps/opencs/model/world/columns.cpp index fef5d99659..050b65a36a 100644 --- a/apps/opencs/model/world/columns.cpp +++ b/apps/opencs/model/world/columns.cpp @@ -629,7 +629,7 @@ std::vector>CSMWorld::Columns::getEnums (ColumnId col { for (int i=0; i<8; i++) { - const std::string& bloodName = Fallback::Map::getString("Blood_Texture_Name_" + std::to_string(i)); + std::string_view bloodName = Fallback::Map::getString("Blood_Texture_Name_" + std::to_string(i)); if (!bloodName.empty()) enums.emplace_back(i, bloodName); } diff --git a/apps/opencs/view/render/cellwater.cpp b/apps/opencs/view/render/cellwater.cpp index 74eb4dddfc..9681e5cdce 100644 --- a/apps/opencs/view/render/cellwater.cpp +++ b/apps/opencs/view/render/cellwater.cpp @@ -162,8 +162,9 @@ namespace CSVRender mWaterGeometry->setStateSet(SceneUtil::createSimpleWaterStateSet(Alpha, RenderBin)); // Add water texture - std::string textureName = Fallback::Map::getString("Water_SurfaceTexture"); - textureName = "textures/water/" + textureName + "00.dds"; + std::string textureName = "textures/water/"; + textureName += Fallback::Map::getString("Water_SurfaceTexture"); + textureName += "00.dds"; Resource::ImageManager* imageManager = mData.getResourceSystem()->getImageManager(); diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 47a400d297..067fe50100 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -850,7 +850,7 @@ void OMW::Engine::prepareEngine() if (!mSkipMenu) { - const std::string& logo = Fallback::Map::getString("Movies_Company_Logo"); + std::string_view logo = Fallback::Map::getString("Movies_Company_Logo"); if (!logo.empty()) mWindowManager->playVideo(logo, true); } @@ -1069,7 +1069,7 @@ void OMW::Engine::go() // start in main menu mWindowManager->pushGuiMode (MWGui::GM_MainMenu); mSoundManager->playTitleMusic(); - const std::string& logo = Fallback::Map::getString("Movies_Morrowind_Logo"); + std::string_view logo = Fallback::Map::getString("Movies_Morrowind_Logo"); if (!logo.empty()) mWindowManager->playVideo(logo, /*allowSkipping*/true, /*overrideSounds*/false); } diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index e3a1a0c725..95eb3e68df 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -108,7 +108,7 @@ namespace MWBase /// @note This method will block until the video finishes playing /// (and will continually update the window while doing so) - virtual void playVideo(const std::string& name, bool allowSkipping, bool overrideSounds = true) = 0; + virtual void playVideo(std::string_view name, bool allowSkipping, bool overrideSounds = true) = 0; virtual void setNewGame(bool newgame) = 0; diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 464a331581..9dbdbfecb0 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -163,7 +163,7 @@ namespace MWClass text += "\n#{sType} "; int skill = MWMechanics::getWeaponType(ref->mBase->mData.mType)->mSkill; - const std::string type = ESM::Skill::sSkillNameIds[skill]; + const std::string& type = ESM::Skill::sSkillNameIds[skill]; std::string_view oneOrTwoHanded; if (weaponType->mWeaponClass == ESM::WeaponType::Melee) { diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index b817decad3..c715db6c7a 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -45,10 +45,10 @@ namespace { number++; - std::string question = Fallback::Map::getString("Question_" + MyGUI::utility::toString(number) + "_Question"); - std::string answer0 = Fallback::Map::getString("Question_" + MyGUI::utility::toString(number) + "_AnswerOne"); - std::string answer1 = Fallback::Map::getString("Question_" + MyGUI::utility::toString(number) + "_AnswerTwo"); - std::string answer2 = Fallback::Map::getString("Question_" + MyGUI::utility::toString(number) + "_AnswerThree"); + std::string question{Fallback::Map::getString("Question_" + MyGUI::utility::toString(number) + "_Question")}; + std::string answer0{Fallback::Map::getString("Question_" + MyGUI::utility::toString(number) + "_AnswerOne")}; + std::string answer1{Fallback::Map::getString("Question_" + MyGUI::utility::toString(number) + "_AnswerTwo")}; + std::string answer2{Fallback::Map::getString("Question_" + MyGUI::utility::toString(number) + "_AnswerThree")}; std::string sound = "vo\\misc\\chargen qa" + MyGUI::utility::toString(number) + ".wav"; Response r0 = {answer0, ESM::Class::Combat}; diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 9acb043820..080a9f6fd0 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -768,8 +768,8 @@ namespace MWGui if (!Settings::Manager::getBool("color topic enable", "GUI")) return; - std::string specialColour = Settings::Manager::getString("color topic specific", "GUI"); - std::string oldColour = Settings::Manager::getString("color topic exhausted", "GUI"); + const std::string& specialColour = Settings::Manager::getString("color topic specific", "GUI"); + const std::string& oldColour = Settings::Manager::getString("color topic exhausted", "GUI"); for (const std::string& keyword : mKeywords) { diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 9c4c4a1b7e..1d6b981bcd 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -393,7 +393,7 @@ namespace MWGui const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().find(spellId); - std::string spellName = spell->mName; + const std::string& spellName = spell->mName; if (spellName != mSpellName && mSpellVisible) { mWeaponSpellTimer = 5.0f; @@ -463,7 +463,7 @@ namespace MWGui void HUD::unsetSelectedSpell() { - std::string spellName = "#{sNone}"; + std::string_view spellName = "#{sNone}"; if (spellName != mSpellName && mSpellVisible) { mWeaponSpellTimer = 5.0f; diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index e7e30b76cf..1dfaa0d047 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -791,7 +791,7 @@ namespace MWGui int incr = next ? 1 : -1; bool found = false; - std::string lastId; + std::string_view lastId; if (selected != -1) lastId = model.getItem(selected).mBase.getCellRef().getRefId(); ItemModel::ModelIndex cycled = selected; diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index 14de3fd274..a4609ec16a 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -18,6 +18,7 @@ #include "../mwmechanics/actorutil.hpp" #include "class.hpp" +#include "ustring.hpp" namespace MWGui { @@ -138,13 +139,13 @@ namespace MWGui int level = creatureStats.getLevel ()+1; mLevelText->setCaptionWithReplacing("#{sLevelUpMenu1} " + MyGUI::utility::toString(level)); - std::string levelupdescription; + std::string_view levelupdescription; levelupdescription = Fallback::Map::getString("Level_Up_Level"+MyGUI::utility::toString(level)); - if (levelupdescription == "") + if (levelupdescription.empty()) levelupdescription = Fallback::Map::getString("Level_Up_Default"); - mLevelDescription->setCaption (levelupdescription); + mLevelDescription->setCaption(toUString(levelupdescription)); unsigned int availableAttributes = 0; for (int i = 0; i < 8; ++i) diff --git a/apps/openmw/mwgui/mainmenu.cpp b/apps/openmw/mwgui/mainmenu.cpp index 8fff838add..d77a2d0bcd 100644 --- a/apps/openmw/mwgui/mainmenu.cpp +++ b/apps/openmw/mwgui/mainmenu.cpp @@ -93,7 +93,7 @@ namespace MWGui { MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager(); - std::string name = *sender->getUserData(); + const std::string& name = *sender->getUserData(); winMgr->playSound("Menu Click"); if (name == "return") { diff --git a/apps/openmw/mwgui/postprocessorhud.cpp b/apps/openmw/mwgui/postprocessorhud.cpp index fc77f1e841..b7a25405b2 100644 --- a/apps/openmw/mwgui/postprocessorhud.cpp +++ b/apps/openmw/mwgui/postprocessorhud.cpp @@ -287,16 +287,16 @@ namespace MWGui while (mConfigArea->getChildCount() > 0) MyGUI::Gui::getInstance().destroyWidget(mConfigArea->getChildAt(0)); - mShaderInfo->setCaption(""); + mShaderInfo->setCaption({}); std::ostringstream ss; - const std::string NA = "#{Interface:NotAvailableShort}"; - const std::string endl = "\n"; + const std::string_view NA = "#{Interface:NotAvailableShort}"; + const char endl = '\n'; - std::string author = technique->getAuthor().empty() ? NA : std::string(technique->getAuthor()); - std::string version = technique->getVersion().empty() ? NA : std::string(technique->getVersion()); - std::string description = technique->getDescription().empty() ? NA : std::string(technique->getDescription()); + std::string_view author = technique->getAuthor().empty() ? NA : technique->getAuthor(); + std::string_view version = technique->getVersion().empty() ? NA : technique->getVersion(); + std::string_view description = technique->getDescription().empty() ? NA : technique->getDescription(); auto serializeBool = [](bool value) { return value ? "#{sYes}" : "#{sNo}"; diff --git a/apps/openmw/mwgui/recharge.cpp b/apps/openmw/mwgui/recharge.cpp index 3b3a754468..4c6a80540d 100644 --- a/apps/openmw/mwgui/recharge.cpp +++ b/apps/openmw/mwgui/recharge.cpp @@ -68,7 +68,7 @@ void Recharge::updateView() { MWWorld::Ptr gem = *mGemIcon->getUserData(); - std::string soul = gem.getCellRef().getSoul(); + const std::string& soul = gem.getCellRef().getSoul(); const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get().find(soul); mChargeLabel->setCaptionWithReplacing("#{sCharges} " + MyGUI::utility::toString(creature->mData.mSoul)); diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index 15ead5d887..86295e3e82 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -30,6 +30,7 @@ #include "../mwstate/character.hpp" #include "confirmationdialog.hpp" +#include "ustring.hpp" namespace MWGui { @@ -176,7 +177,7 @@ namespace MWGui // For a custom class, we will not find it in the store (unless we loaded the savegame first). // Fall back to name stored in savegame header in that case. - std::string className; + std::string_view className; if (it->getSignature().mPlayerClassId.empty()) className = it->getSignature().mPlayerClassName; else @@ -190,7 +191,7 @@ namespace MWGui className = "?"; // From an older savegame format that did not support custom classes properly. } - title << " (#{sLevel} " << it->getSignature().mPlayerLevel << " " << MyGUI::TextIterator::toTagsString(className) << ")"; + title << " (#{sLevel} " << it->getSignature().mPlayerLevel << " " << MyGUI::TextIterator::toTagsString(toUString(className)) << ")"; mCharacterSelection->addItem (MyGUI::LanguageManager::getInstance().replaceTags(title.str())); diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index a646324c13..a249f1e203 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -238,7 +238,7 @@ namespace MWGui , mCurrentPage(-1) { bool terrain = Settings::Manager::getBool("distant terrain", "Terrain"); - const std::string widgetName = terrain ? "RenderingDistanceSlider" : "LargeRenderingDistanceSlider"; + const std::string_view widgetName = terrain ? "RenderingDistanceSlider" : "LargeRenderingDistanceSlider"; MyGUI::Widget* unusedSlider; getWidget(unusedSlider, widgetName); unusedSlider->setVisible(false); @@ -338,7 +338,7 @@ namespace MWGui } highlightCurrentResolution(); - std::string tmip = Settings::Manager::getString("texture mipmap", "General"); + const std::string& tmip = Settings::Manager::getString("texture mipmap", "General"); mTextureFilteringButton->setCaptionWithReplacing(textureMipmappingToStr(tmip)); int waterTextureSize = Settings::Manager::getInt("rtt size", "Water"); diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index 7bd56c878d..dae157f511 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -34,10 +34,7 @@ namespace MWGui bool SpellBuyingWindow::sortSpells (const ESM::Spell* left, const ESM::Spell* right) { - std::string leftName = Misc::StringUtils::lowerCase(left->mName); - std::string rightName = Misc::StringUtils::lowerCase(right->mName); - - return leftName.compare(rightName) < 0; + return Misc::StringUtils::ciLess(left->mName, right->mName); } void SpellBuyingWindow::addSpell(const ESM::Spell& spell) diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 02b6ab8db6..a54c5c87f3 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -555,7 +555,7 @@ namespace MWGui for (const short effectId : knownEffects) { - std::string name = MWBase::Environment::get().getWorld ()->getStore ().get().find( + const std::string& name = MWBase::Environment::get().getWorld ()->getStore ().get().find( ESM::MagicEffect::effectIdToString(effectId))->mValue.getString(); MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name); diff --git a/apps/openmw/mwgui/spellicons.cpp b/apps/openmw/mwgui/spellicons.cpp index 2f1da5857c..60ea47683b 100644 --- a/apps/openmw/mwgui/spellicons.cpp +++ b/apps/openmw/mwgui/spellicons.cpp @@ -149,7 +149,7 @@ namespace MWGui image->setImageTexture(Misc::ResourceHelpers::correctIconPath(effect->mIcon, MWBase::Environment::get().getResourceSystem()->getVFS())); - std::string name = ESM::MagicEffect::effectIdToString (effectId); + const std::string& name = ESM::MagicEffect::effectIdToString(effectId); ToolTipInfo tooltipInfo; tooltipInfo.caption = "#{" + name + "}"; diff --git a/apps/openmw/mwgui/spellwindow.cpp b/apps/openmw/mwgui/spellwindow.cpp index c39341aeb4..20db95fc19 100644 --- a/apps/openmw/mwgui/spellwindow.cpp +++ b/apps/openmw/mwgui/spellwindow.cpp @@ -147,7 +147,7 @@ namespace MWGui MWBase::Environment::get().getWorld()->getStore().get().find(spellId); MWWorld::Ptr player = MWMechanics::getPlayer(); - std::string raceId = player.get()->mBase->mRace; + const std::string& raceId = player.get()->mBase->mRace; const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(raceId); // can't delete racial spells, birthsign spells or powers bool isInherent = race->mPowers.exists(spell->mId) || spell->mData.mType == ESM::Spell::ST_Power; diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 353a88004e..94c4288ddf 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -400,9 +400,9 @@ namespace MWGui else mDynamicToolTipBox->changeWidgetSkin(MWBase::Environment::get().getWindowManager()->isGuiMode() ? "HUD_Box_NoTransp" : "HUD_Box"); - std::string caption = info.caption; - std::string image = info.icon; - int imageSize = (image != "") ? info.imageSize : 0; + const std::string& caption = info.caption; + const std::string& image = info.icon; + int imageSize = (!image.empty()) ? info.imageSize : 0; std::string text = info.text; // remove the first newline (easier this way) @@ -411,7 +411,7 @@ namespace MWGui const ESM::Enchantment* enchant = nullptr; const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); - if (info.enchant != "") + if (!info.enchant.empty()) { enchant = store.get().search(info.enchant); if (enchant) @@ -432,8 +432,8 @@ namespace MWGui const MyGUI::IntPoint padding(8, 8); - const int imageCaptionHPadding = (caption != "" ? 8 : 0); - const int imageCaptionVPadding = (caption != "" ? 4 : 0); + const int imageCaptionHPadding = !caption.empty() ? 8 : 0; + const int imageCaptionVPadding = !caption.empty() ? 4 : 0; const int maximumWidth = MyGUI::RenderManager::getInstance().getViewSize().width - imageCaptionHPadding * 2; @@ -446,7 +446,7 @@ namespace MWGui captionWidget->setCaptionWithReplacing(caption); MyGUI::IntSize captionSize = captionWidget->getTextSize(); - int captionHeight = std::max(caption != "" ? captionSize.height : 0, imageSize); + int captionHeight = std::max(!caption.empty() ? captionSize.height : 0, imageSize); Gui::EditBox* textWidget = mDynamicToolTipBox->createWidget("SandText", MyGUI::IntCoord(0, captionHeight+imageCaptionVPadding, 300, 300-captionHeight-imageCaptionVPadding), MyGUI::Align::Stretch, "ToolTipText"); textWidget->setEditStatic(true); @@ -458,8 +458,8 @@ namespace MWGui MyGUI::IntSize textSize = textWidget->getTextSize(); captionSize += MyGUI::IntSize(imageSize, 0); // adjust for image - MyGUI::IntSize totalSize = MyGUI::IntSize( std::min(std::max(textSize.width,captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),maximumWidth), - ((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight ); + MyGUI::IntSize totalSize = MyGUI::IntSize( std::min(std::max(textSize.width,captionSize.width + ((!image.empty()) ? imageCaptionHPadding : 0)),maximumWidth), + (!text.empty() ? textSize.height + imageCaptionVPadding : 0) + captionHeight ); for (const std::string& note : info.notes) { @@ -578,7 +578,7 @@ namespace MWGui textWidget->setPosition (textWidget->getPosition() + MyGUI::IntPoint(0, padding.top)); // only apply vertical padding, the horizontal works automatically due to Align::HCenter - if (image != "") + if (!image.empty()) { MyGUI::ImageBox* imageWidget = mDynamicToolTipBox->createWidget("ImageBox", MyGUI::IntCoord((totalSize.width - captionSize.width - imageCaptionHPadding)/2, 0, imageSize, imageSize), @@ -611,7 +611,7 @@ namespace MWGui std::string ToolTips::getWeightString(const float weight, const std::string& prefix) { if (weight == 0) - return ""; + return {}; else return "\n" + prefix + ": " + toString(weight); } @@ -619,7 +619,7 @@ namespace MWGui std::string ToolTips::getPercentString(const float value, const std::string& prefix) { if (value == 0) - return ""; + return {}; else return "\n" + prefix + ": " + toString(value*100) +"%"; } @@ -627,15 +627,15 @@ namespace MWGui std::string ToolTips::getValueString(const int value, const std::string& prefix) { if (value == 0) - return ""; + return {}; else return "\n" + prefix + ": " + toString(value); } std::string ToolTips::getMiscString(const std::string& text, const std::string& prefix) { - if (text == "") - return ""; + if (text.empty()) + return {}; else return "\n" + prefix + ": " + text; } @@ -643,7 +643,7 @@ namespace MWGui std::string ToolTips::getCountString(const int value) { if (value == 1) - return ""; + return {}; else return " (" + MyGUI::utility::toString(value) + ")"; } @@ -652,11 +652,11 @@ namespace MWGui { const std::string& soul = cellref.getSoul(); if (soul.empty()) - return std::string(); + return {}; const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Creature *creature = store.get().search(soul); if (!creature) - return std::string(); + return {}; if (creature->mName.empty()) return " (" + creature->mId + ")"; return " (" + creature->mName + ")"; @@ -677,7 +677,7 @@ namespace MWGui if (cellref.getFactionRank() >= 0) { int rank = cellref.getFactionRank(); - const std::string rankName = fact->mRanks[rank]; + const std::string& rankName = fact->mRanks[rank]; if (rankName.empty()) ret += getValueString(cellref.getFactionRank(), "Rank"); else @@ -802,9 +802,9 @@ namespace MWGui if (attributeId == -1) return; - std::string icon = ESM::Attribute::sAttributeIcons[attributeId]; - std::string name = ESM::Attribute::sGmstAttributeIds[attributeId]; - std::string desc = ESM::Attribute::sGmstAttributeDescIds[attributeId]; + const std::string& icon = ESM::Attribute::sAttributeIcons[attributeId]; + const std::string& name = ESM::Attribute::sGmstAttributeIds[attributeId]; + const std::string& desc = ESM::Attribute::sGmstAttributeDescIds[attributeId]; widget->setUserString("ToolTipType", "Layout"); widget->setUserString("ToolTipLayout", "AttributeToolTip"); @@ -850,12 +850,9 @@ namespace MWGui widget->setUserString("ToolTipType", "Layout"); widget->setUserString("ToolTipLayout", "BirthSignToolTip"); widget->setUserString("ImageTexture_BirthSignImage", Misc::ResourceHelpers::correctTexturePath(sign->mTexture, vfs)); - std::string text; + std::string text = sign->mName + "\n#{fontcolourhtml=normal}" + sign->mDescription; - text += sign->mName; - text += "\n#{fontcolourhtml=normal}" + sign->mDescription; - - std::vector abilities, powers, spells; + std::vector abilities, powers, spells; for (const std::string& spellId : sign->mPowers.mList) { @@ -867,35 +864,27 @@ namespace MWGui continue; // We only want spell, ability and powers. if (type == ESM::Spell::ST_Ability) - abilities.push_back(spellId); + abilities.push_back(spell); else if (type == ESM::Spell::ST_Power) - powers.push_back(spellId); + powers.push_back(spell); else if (type == ESM::Spell::ST_Spell) - spells.push_back(spellId); - } - - struct { - const std::vector &spells; - std::string label; + spells.push_back(spell); } - categories[3] = { - {abilities, "sBirthsignmenu1"}, - {powers, "sPowers"}, - {spells, "sBirthsignmenu2"} - }; - for (int category = 0; category < 3; ++category) + using Category = std::pair&, std::string_view>; + for (const auto&[category, label] : std::initializer_list{{abilities, "sBirthsignmenu1"}, {powers, "sPowers"}, {spells, "sBirthsignmenu2"}}) { bool addHeader = true; - for (const std::string& spellId : categories[category].spells) + for (const ESM::Spell* spell : category) { if (addHeader) { - text += std::string("\n\n#{fontcolourhtml=header}") + std::string("#{") + categories[category].label + "}"; + text += "\n\n#{fontcolourhtml=header}#{"; + text += label; + text += '}'; addHeader = false; } - const ESM::Spell *spell = store.get().find(spellId); text += "\n#{fontcolourhtml=normal}" + spell->mName; } } diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 22833c4796..600e77ae51 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1806,9 +1806,9 @@ namespace MWGui && (!isGuiMode() || (mGuiModes.size() == 1 && (getMode() == GM_MainMenu || getMode() == GM_Rest))); } - void WindowManager::playVideo(const std::string &name, bool allowSkipping, bool overrideSounds) + void WindowManager::playVideo(std::string_view name, bool allowSkipping, bool overrideSounds) { - mVideoWidget->playVideo("video\\" + name); + mVideoWidget->playVideo("video\\" + std::string{name}); mVideoWidget->eventKeyButtonPressed.clear(); mVideoBackground->eventKeyButtonPressed.clear(); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 14a7f89115..0b506d17a2 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -149,7 +149,7 @@ namespace MWGui /// @note This method will block until the video finishes playing /// (and will continually update the window while doing so) - void playVideo(const std::string& name, bool allowSkipping, bool overrideSounds = true) override; + void playVideo(std::string_view name, bool allowSkipping, bool overrideSounds = true) override; /// Warning: do not use MyGUI::InputManager::setKeyFocusWidget directly. Instead use this. void setKeyFocusWidget (MyGUI::Widget* widget) override; diff --git a/apps/openmw/mwmechanics/aipackage.cpp b/apps/openmw/mwmechanics/aipackage.cpp index 58e8c4d901..edaa481f10 100644 --- a/apps/openmw/mwmechanics/aipackage.cpp +++ b/apps/openmw/mwmechanics/aipackage.cpp @@ -300,7 +300,7 @@ void MWMechanics::AiPackage::openDoors(const MWWorld::Ptr& actor) return; } - const std::string keyId = door.getCellRef().getKey(); + const std::string& keyId = door.getCellRef().getKey(); if (keyId.empty()) return; diff --git a/apps/openmw/mwmechanics/disease.hpp b/apps/openmw/mwmechanics/disease.hpp index 034561ad92..e182886059 100644 --- a/apps/openmw/mwmechanics/disease.hpp +++ b/apps/openmw/mwmechanics/disease.hpp @@ -60,8 +60,7 @@ namespace MWMechanics actor.getClass().getCreatureStats(actor).getSpells().add(spell); MWBase::Environment::get().getWorld()->applyLoopingParticles(actor); - std::string msg = "sMagicContractDisease"; - msg = MWBase::Environment::get().getWorld()->getStore().get().find(msg)->mValue.getString(); + std::string msg = MWBase::Environment::get().getWorld()->getStore().get().find("sMagicContractDisease")->mValue.getString(); msg = Misc::StringUtils::format(msg, spell->mName); MWBase::Environment::get().getWindowManager()->messageBox(msg); } diff --git a/apps/openmw/mwrender/effectmanager.cpp b/apps/openmw/mwrender/effectmanager.cpp index 371f488c3d..6b1543eda9 100644 --- a/apps/openmw/mwrender/effectmanager.cpp +++ b/apps/openmw/mwrender/effectmanager.cpp @@ -27,7 +27,7 @@ EffectManager::~EffectManager() clear(); } -void EffectManager::addEffect(const std::string &model, const std::string& textureOverride, const osg::Vec3f &worldPosition, float scale, bool isMagicVFX) +void EffectManager::addEffect(const std::string& model, std::string_view textureOverride, const osg::Vec3f& worldPosition, float scale, bool isMagicVFX) { osg::ref_ptr node = mResourceSystem->getSceneManager()->getInstance(model); diff --git a/apps/openmw/mwrender/effectmanager.hpp b/apps/openmw/mwrender/effectmanager.hpp index 0d94a63c8f..f974a3a01e 100644 --- a/apps/openmw/mwrender/effectmanager.hpp +++ b/apps/openmw/mwrender/effectmanager.hpp @@ -33,7 +33,7 @@ namespace MWRender ~EffectManager(); /// Add an effect. When it's finished playing, it will be removed automatically. - void addEffect (const std::string& model, const std::string& textureOverride, const osg::Vec3f& worldPosition, float scale, bool isMagicVFX = true); + void addEffect(const std::string& model, std::string_view textureOverride, const osg::Vec3f& worldPosition, float scale, bool isMagicVFX = true); void update(float dt); diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index deb44c14d5..421a7e622f 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -514,7 +514,7 @@ void NpcAnimation::updateNpcBase() if(!is1stPerson) { - const std::string base = Settings::Manager::getString("xbaseanim", "Models"); + const std::string& base = Settings::Manager::getString("xbaseanim", "Models"); if (smodel != base && !isWerewolf) addAnimSource(base, smodel); @@ -528,7 +528,7 @@ void NpcAnimation::updateNpcBase() } else { - const std::string base = Settings::Manager::getString("xbaseanim1st", "Models"); + const std::string& base = Settings::Manager::getString("xbaseanim1st", "Models"); if (smodel != base && !isWerewolf) addAnimSource(base, smodel); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 1385147c4c..bf0d2e3baa 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -493,9 +493,9 @@ namespace MWRender mEffectManager = std::make_unique(sceneRoot, mResourceSystem); - const std::string normalMapPattern = Settings::Manager::getString("normal map pattern", "Shaders"); - const std::string heightMapPattern = Settings::Manager::getString("normal height map pattern", "Shaders"); - const std::string specularMapPattern = Settings::Manager::getString("terrain specular map pattern", "Shaders"); + const std::string& normalMapPattern = Settings::Manager::getString("normal map pattern", "Shaders"); + const std::string& heightMapPattern = Settings::Manager::getString("normal height map pattern", "Shaders"); + const std::string& specularMapPattern = Settings::Manager::getString("terrain specular map pattern", "Shaders"); const bool useTerrainNormalMaps = Settings::Manager::getBool("auto use terrain normal maps", "Shaders"); const bool useTerrainSpecularMaps = Settings::Manager::getBool("auto use terrain specular maps", "Shaders"); @@ -1174,7 +1174,7 @@ namespace MWRender mActorsPaths->updatePtr(old, updated); } - void RenderingManager::spawnEffect(const std::string &model, const std::string &texture, const osg::Vec3f &worldPosition, float scale, bool isMagicVFX) + void RenderingManager::spawnEffect(const std::string& model, std::string_view texture, const osg::Vec3f& worldPosition, float scale, bool isMagicVFX) { mEffectManager->addEffect(model, texture, worldPosition, scale, isMagicVFX); } diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 83dfd32287..68a77c39f3 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -184,7 +184,7 @@ namespace MWRender SkyManager* getSkyManager(); - void spawnEffect(const std::string &model, const std::string &texture, const osg::Vec3f &worldPosition, float scale = 1.f, bool isMagicVFX = true); + void spawnEffect(const std::string& model, std::string_view texture, const osg::Vec3f& worldPosition, float scale = 1.f, bool isMagicVFX = true); /// Clear all savegame-specific data void clear(); diff --git a/apps/openmw/mwrender/ripplesimulation.cpp b/apps/openmw/mwrender/ripplesimulation.cpp index 037ed4455f..0bb92cdd49 100644 --- a/apps/openmw/mwrender/ripplesimulation.cpp +++ b/apps/openmw/mwrender/ripplesimulation.cpp @@ -34,7 +34,7 @@ namespace if (rippleFrameCount <= 0) return; - const std::string& tex = Fallback::Map::getString("Water_RippleTexture"); + std::string_view tex = Fallback::Map::getString("Water_RippleTexture"); std::vector > textures; for (int i=0; i > textures; const int frameCount = std::clamp(Fallback::Map::getInt("Water_SurfaceFrameCount"), 0, 320); - const std::string& texture = Fallback::Map::getString("Water_SurfaceTexture"); + std::string_view texture = Fallback::Map::getString("Water_SurfaceTexture"); for (int i=0; i &textures) { const int frameCount = std::clamp(Fallback::Map::getInt("Water_SurfaceFrameCount"), 0, 320); - const std::string& texture = Fallback::Map::getString("Water_SurfaceTexture"); + std::string_view texture = Fallback::Map::getString("Water_SurfaceTexture"); for (int i=0; i 0 ? HrtfMode::Enable : HrtfMode::Disable; - std::string devname = Settings::Manager::getString("device", "Sound"); + const std::string& devname = Settings::Manager::getString("device", "Sound"); if(!mOutput->init(devname, hrtfname, hrtfmode)) { Log(Debug::Error) << "Failed to initialize audio output, sound disabled"; diff --git a/apps/openmw/mwworld/actionsoulgem.cpp b/apps/openmw/mwworld/actionsoulgem.cpp index b416581fa7..dae0a4503f 100644 --- a/apps/openmw/mwworld/actionsoulgem.cpp +++ b/apps/openmw/mwworld/actionsoulgem.cpp @@ -30,7 +30,7 @@ namespace MWWorld } const auto& target = getTarget(); - const std::string targetSoul = target.getCellRef().getSoul(); + const std::string& targetSoul = target.getCellRef().getSoul(); if (targetSoul.empty()) { diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index f1288ee548..5f6df78b50 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -137,7 +137,7 @@ void MWWorld::ContainerStore::storeStates (const CellRefList& collection, } } -const std::string MWWorld::ContainerStore::sGoldId = "gold_001"; +const std::string_view MWWorld::ContainerStore::sGoldId = "gold_001"; MWWorld::ContainerStore::ContainerStore() : mListener(nullptr) diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index f7f569ec97..94207e1df2 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -90,7 +90,7 @@ namespace MWWorld static constexpr int Type_All = 0xffff; - static const std::string sGoldId; + static const std::string_view sGoldId; protected: ContainerStoreListener* mListener; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index a98e1b841d..006825e3e6 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -271,7 +271,7 @@ namespace MWWorld if (!bypass) { - const std::string& video = Fallback::Map::getString("Movies_New_Game"); + std::string_view video = Fallback::Map::getString("Movies_New_Game"); if (!video.empty()) MWBase::Environment::get().getWindowManager()->playVideo(video, true); } @@ -3713,12 +3713,12 @@ namespace MWWorld if (ptr == getPlayerPtr() && Settings::Manager::getBool("hit fader", "GUI")) return; - std::string texture = Fallback::Map::getString("Blood_Texture_" + std::to_string(ptr.getClass().getBloodTexture(ptr))); + std::string_view texture = Fallback::Map::getString("Blood_Texture_" + std::to_string(ptr.getClass().getBloodTexture(ptr))); if (texture.empty()) texture = Fallback::Map::getString("Blood_Texture_0"); std::string model = Misc::ResourceHelpers::correctMeshPath( - Fallback::Map::getString("Blood_Model_" + std::to_string(Misc::Rng::rollDice(3))), // [0, 2] + std::string{Fallback::Map::getString("Blood_Model_" + std::to_string(Misc::Rng::rollDice(3)))}, // [0, 2] mResourceSystem->getVFS()); mRendering->spawnEffect(model, texture, worldPosition, 1.0f, false); diff --git a/components/fallback/fallback.cpp b/components/fallback/fallback.cpp index a151bd40b6..361f7b71fc 100644 --- a/components/fallback/fallback.cpp +++ b/components/fallback/fallback.cpp @@ -6,29 +6,31 @@ namespace Fallback { - std::map Map::mFallbackMap; + std::map> Map::mFallbackMap; void Map::init(const std::map& fallback) { - mFallbackMap = fallback; + for(const auto& entry : fallback) + mFallbackMap.insert(entry); } - std::string Map::getString(const std::string& fall) + std::string_view Map::getString(std::string_view fall) { - std::map::const_iterator it; - if ((it = mFallbackMap.find(fall)) == mFallbackMap.end()) + auto it = mFallbackMap.find(fall); + if (it == mFallbackMap.end()) { - return std::string(); + return {}; } return it->second; } - float Map::getFloat(const std::string& fall) + float Map::getFloat(std::string_view fall) { - const std::string& fallback = getString(fall); + std::string_view fallback = getString(fall); if (!fallback.empty()) { - std::stringstream stream(fallback); + std::stringstream stream; + stream << fallback; float number = 0.f; stream >> number; return number; @@ -37,12 +39,13 @@ namespace Fallback return 0; } - int Map::getInt(const std::string& fall) + int Map::getInt(std::string_view fall) { - const std::string& fallback = getString(fall); + std::string_view fallback = getString(fall); if (!fallback.empty()) { - std::stringstream stream(fallback); + std::stringstream stream; + stream << fallback; int number = 0; stream >> number; return number; @@ -51,15 +54,15 @@ namespace Fallback return 0; } - bool Map::getBool(const std::string& fall) + bool Map::getBool(std::string_view fall) { - const std::string& fallback = getString(fall); + std::string_view fallback = getString(fall); return !fallback.empty() && fallback != "0"; } - osg::Vec4f Map::getColour(const std::string& fall) + osg::Vec4f Map::getColour(std::string_view fall) { - const std::string& sum = getString(fall); + std::string_view sum = getString(fall); if (!sum.empty()) { try diff --git a/components/fallback/fallback.hpp b/components/fallback/fallback.hpp index 75a73be5d7..8eb7440cfa 100644 --- a/components/fallback/fallback.hpp +++ b/components/fallback/fallback.hpp @@ -3,6 +3,7 @@ #include #include +#include #include @@ -11,15 +12,15 @@ namespace Fallback /// @brief contains settings imported from the Morrowind INI file. class Map { - static std::map mFallbackMap; + static std::map> mFallbackMap; public: static void init(const std::map& fallback); - static std::string getString(const std::string& fall); - static float getFloat(const std::string& fall); - static int getInt(const std::string& fall); - static bool getBool(const std::string& fall); - static osg::Vec4f getColour(const std::string& fall); + static std::string_view getString(std::string_view fall); + static float getFloat(std::string_view fall); + static int getInt(std::string_view fall); + static bool getBool(std::string_view fall); + static osg::Vec4f getColour(std::string_view fall); }; } #endif diff --git a/components/fontloader/fontloader.cpp b/components/fontloader/fontloader.cpp index cafc97ba6b..935667e376 100644 --- a/components/fontloader/fontloader.cpp +++ b/components/fontloader/fontloader.cpp @@ -212,8 +212,8 @@ namespace Gui void FontLoader::loadFonts() { - std::string defaultFont = Fallback::Map::getString("Fonts_Font_0"); - std::string scrollFont = Fallback::Map::getString("Fonts_Font_2"); + std::string defaultFont{Fallback::Map::getString("Fonts_Font_0")}; + std::string scrollFont{Fallback::Map::getString("Fonts_Font_2")}; loadFont(defaultFont, "DefaultFont"); loadFont(scrollFont, "ScrollFont"); loadFont("DejaVuLGCSansMono", "MonoFont"); // We need to use a TrueType monospace font to display debug texts properly. diff --git a/components/sceneutil/actorutil.cpp b/components/sceneutil/actorutil.cpp index a0785e413d..c13cd093bf 100644 --- a/components/sceneutil/actorutil.cpp +++ b/components/sceneutil/actorutil.cpp @@ -4,7 +4,7 @@ namespace SceneUtil { - std::string getActorSkeleton(bool firstPerson, bool isFemale, bool isBeast, bool isWerewolf) + const std::string& getActorSkeleton(bool firstPerson, bool isFemale, bool isBeast, bool isWerewolf) { if (!firstPerson) { diff --git a/components/sceneutil/actorutil.hpp b/components/sceneutil/actorutil.hpp index 7bdbbaa922..038fc4e15e 100644 --- a/components/sceneutil/actorutil.hpp +++ b/components/sceneutil/actorutil.hpp @@ -5,7 +5,7 @@ namespace SceneUtil { - std::string getActorSkeleton(bool firstPerson, bool female, bool beast, bool werewolf); + const std::string& getActorSkeleton(bool firstPerson, bool female, bool beast, bool werewolf); } #endif diff --git a/components/sceneutil/lightmanager.cpp b/components/sceneutil/lightmanager.cpp index a861dcd32c..76e1ea852e 100644 --- a/components/sceneutil/lightmanager.cpp +++ b/components/sceneutil/lightmanager.cpp @@ -814,7 +814,7 @@ namespace SceneUtil return; } - std::string lightingMethodString = Settings::Manager::getString("lighting method", "Shaders"); + const std::string& lightingMethodString = Settings::Manager::getString("lighting method", "Shaders"); auto lightingMethod = LightManager::getLightingMethodFromString(lightingMethodString); static bool hasLoggedWarnings = false; diff --git a/components/sceneutil/shadow.cpp b/components/sceneutil/shadow.cpp index 8727dec37d..d1d0fc3251 100644 --- a/components/sceneutil/shadow.cpp +++ b/components/sceneutil/shadow.cpp @@ -43,10 +43,10 @@ namespace SceneUtil mShadowSettings->setMinimumShadowMapNearFarRatio(Settings::Manager::getFloat("minimum lispsm near far ratio", "Shadows")); - std::string computeSceneBounds = Settings::Manager::getString("compute scene bounds", "Shadows"); - if (Misc::StringUtils::lowerCase(computeSceneBounds) == "primitives") + const std::string& computeSceneBounds = Settings::Manager::getString("compute scene bounds", "Shadows"); + if (Misc::StringUtils::ciEqual(computeSceneBounds, "primitives")) mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES); - else if (Misc::StringUtils::lowerCase(computeSceneBounds) == "bounds") + else if (Misc::StringUtils::ciEqual(computeSceneBounds, "bounds")) mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES); int mapres = Settings::Manager::getInt("shadow map resolution", "Shadows"); diff --git a/components/settings/settings.cpp b/components/settings/settings.cpp index 6591fd005b..d77f814468 100644 --- a/components/settings/settings.cpp +++ b/components/settings/settings.cpp @@ -71,7 +71,7 @@ void Manager::saveUser(const std::string &file) parser.saveSettingsFile(file, mUserSettings); } -std::string Manager::getString(std::string_view setting, std::string_view category) +const std::string& Manager::getString(std::string_view setting, std::string_view category) { const auto key = std::make_pair(category, setting); CategorySettingValueMap::iterator it = mUserSettings.find(key); diff --git a/components/settings/settings.hpp b/components/settings/settings.hpp index 178b8d3ebc..f50449b5de 100644 --- a/components/settings/settings.hpp +++ b/components/settings/settings.hpp @@ -63,7 +63,7 @@ namespace Settings static std::int64_t getInt64(std::string_view setting, std::string_view category); static float getFloat(std::string_view setting, std::string_view category); static double getDouble(std::string_view setting, std::string_view category); - static std::string getString(std::string_view setting, std::string_view category); + static const std::string& getString(std::string_view setting, std::string_view category); static std::vector getStringArray(std::string_view setting, std::string_view category); static bool getBool(std::string_view setting, std::string_view category); static osg::Vec2f getVector2(std::string_view setting, std::string_view category); diff --git a/components/widgets/tags.cpp b/components/widgets/tags.cpp index e3575ea8f5..93b0fca447 100644 --- a/components/widgets/tags.cpp +++ b/components/widgets/tags.cpp @@ -18,7 +18,7 @@ bool replaceTag(const MyGUI::UString& tag, MyGUI::UString& out) if (tag.compare(0, fontcolourLength, fontcolour) == 0) { std::string fallbackName = "FontColor_color_" + tag.substr(fontcolourLength); - std::string str = Fallback::Map::getString(fallbackName); + std::string_view str = Fallback::Map::getString(fallbackName); if (str.empty()) throw std::runtime_error("Unknown fallback name: " + fallbackName); @@ -36,7 +36,7 @@ bool replaceTag(const MyGUI::UString& tag, MyGUI::UString& out) else if (tag.compare(0, fontcolourhtmlLength, fontcolourhtml) == 0) { std::string fallbackName = "FontColor_color_" + tag.substr(fontcolourhtmlLength); - std::string str = Fallback::Map::getString(fallbackName); + std::string_view str = Fallback::Map::getString(fallbackName); if (str.empty()) throw std::runtime_error("Unknown fallback name: " + fallbackName);