1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-17 01:10:10 +00:00

refactor saveGame to use string_view instead of a const standard string reference

This commit is contained in:
Christian Bouwense 2023-07-23 14:40:46 -04:00
parent 935a7a2a57
commit 7d0caf9eec
4 changed files with 5 additions and 4 deletions

View File

@ -55,7 +55,7 @@ namespace MWBase
virtual void deleteGame(const MWState::Character* character, const MWState::Slot* slot) = 0;
virtual void saveGame(const std::string& description, const MWState::Slot* slot = nullptr) = 0;
virtual void saveGame(std::string_view description, const MWState::Slot* slot = nullptr) = 0;
///< Write a saved game to \a slot or create a new slot if \a slot == 0.
///
/// \note Slot must belong to the current character.

View File

@ -301,7 +301,8 @@ namespace MWGui
if (mSaving)
{
MWBase::Environment::get().getStateManager()->saveGame(mSaveNameEdit->getCaption(), mCurrentSlot);
std::string_view nameAsStringView = std::basic_string_view(mSaveNameEdit->getCaption().asUTF8().c_str());
MWBase::Environment::get().getStateManager()->saveGame(nameAsStringView, mCurrentSlot);
}
else
{

View File

@ -188,7 +188,7 @@ void MWState::StateManager::resumeGame()
mState = State_Running;
}
void MWState::StateManager::saveGame(const std::string& description, const Slot* slot)
void MWState::StateManager::saveGame(std::string_view description, const Slot* slot)
{
MWState::Character* character = getCurrentCharacter();

View File

@ -51,7 +51,7 @@ namespace MWState
///< Delete a saved game slot from this character. If all save slots are deleted, the character will be deleted
///< too.
void saveGame(const std::string& description, const Slot* slot = nullptr) override;
void saveGame(std::string_view description, const Slot* slot = nullptr) override;
///< Write a saved game to \a slot or create a new slot if \a slot == 0.
///
/// \note Slot must belong to the current character.