mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 20:36:40 +00:00
Retain the use of std::string_view in the function signature.
This commit is contained in:
parent
99e691fbe3
commit
bf06898a79
2 changed files with 4 additions and 4 deletions
|
@ -181,14 +181,14 @@ std::string CSMWorld::RefCollection::getNewId()
|
||||||
return "ref#" + std::to_string(mNextId++);
|
return "ref#" + std::to_string(mNextId++);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CSMWorld::RefCollection::extractIdNum (const std::string& id) const
|
unsigned int CSMWorld::RefCollection::extractIdNum(std::string_view id) const
|
||||||
{
|
{
|
||||||
std::string::size_type separator = id.find_last_of('#');
|
std::string::size_type separator = id.find_last_of('#');
|
||||||
|
|
||||||
if (separator == std::string::npos)
|
if (separator == std::string::npos)
|
||||||
throw std::runtime_error("invalid ref ID: " + id);
|
throw std::runtime_error("invalid ref ID: " + std::string(id));
|
||||||
|
|
||||||
return static_cast<unsigned int>(std::stoi(id.substr(separator+1)));
|
return static_cast<unsigned int>(std::stoi(std::string(id.substr(separator+1))));
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSMWorld::RefCollection::getIntIndex (unsigned int id) const
|
int CSMWorld::RefCollection::getIntIndex (unsigned int id) const
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace CSMWorld
|
||||||
|
|
||||||
int mNextId;
|
int mNextId;
|
||||||
|
|
||||||
unsigned int extractIdNum(const std::string& id) const;
|
unsigned int extractIdNum(std::string_view id) const;
|
||||||
|
|
||||||
int getIntIndex (unsigned int id) const;
|
int getIntIndex (unsigned int id) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue