mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-17 10:10:23 +00:00
Retain the use of std::string_view in the function signature.
This commit is contained in:
parent
99e691fbe3
commit
bf06898a79
@ -181,14 +181,14 @@ std::string CSMWorld::RefCollection::getNewId()
|
||||
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('#');
|
||||
|
||||
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
|
||||
|
@ -29,7 +29,7 @@ namespace CSMWorld
|
||||
|
||||
int mNextId;
|
||||
|
||||
unsigned int extractIdNum(const std::string& id) const;
|
||||
unsigned int extractIdNum(std::string_view id) const;
|
||||
|
||||
int getIntIndex (unsigned int id) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user