Avoid forced string copies

This commit is contained in:
Sven Fink 2020-02-10 14:03:58 +01:00 committed by Patrick Boettcher
parent 7fbda9da0e
commit f20017306f
2 changed files with 10 additions and 10 deletions

View File

@ -44,7 +44,7 @@ void json_uri::update(const std::string &uri)
auto location = uri.substr(0, pointer_separator);
if (location.size()) { // a location part has been found
if (location.size()) { // a location part has been found
// if it is an URN take it as it is
if (location.find("urn:") == 0) {
@ -99,7 +99,7 @@ void json_uri::update(const std::string &uri)
identifier_ = pointer;
}
const std::string json_uri::location() const
std::string json_uri::location() const
{
if (urn_.size())
return urn_;

View File

@ -71,14 +71,14 @@ public:
update(uri);
}
const std::string scheme() const { return scheme_; }
const std::string authority() const { return authority_; }
const std::string path() const { return path_; }
const std::string &scheme() const { return scheme_; }
const std::string &authority() const { return authority_; }
const std::string &path() const { return path_; }
const json::json_pointer pointer() const { return pointer_; }
const std::string identifier() const { return identifier_; }
const json::json_pointer &pointer() const { return pointer_; }
const std::string &identifier() const { return identifier_; }
const std::string fragment() const
std::string fragment() const
{
if (identifier_ == "")
return pointer_;
@ -86,8 +86,8 @@ public:
return identifier_;
}
const std::string url() const { return location(); }
const std::string location() const;
std::string url() const { return location(); }
std::string location() const;
static std::string escape(const std::string &);