From bf06898a79a5460c571b1d6f5b2b9cb7c7f52052 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 4 Aug 2021 08:23:22 +1000 Subject: [PATCH] Retain the use of std::string_view in the function signature. --- apps/opencs/model/world/refcollection.cpp | 6 +++--- apps/opencs/model/world/refcollection.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/world/refcollection.cpp b/apps/opencs/model/world/refcollection.cpp index f47a79accd..4782bde6b9 100644 --- a/apps/opencs/model/world/refcollection.cpp +++ b/apps/opencs/model/world/refcollection.cpp @@ -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(std::stoi(id.substr(separator+1))); + return static_cast(std::stoi(std::string(id.substr(separator+1)))); } int CSMWorld::RefCollection::getIntIndex (unsigned int id) const diff --git a/apps/opencs/model/world/refcollection.hpp b/apps/opencs/model/world/refcollection.hpp index 1bdfda3925..e0e88d721f 100644 --- a/apps/opencs/model/world/refcollection.hpp +++ b/apps/opencs/model/world/refcollection.hpp @@ -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;