Use pass-by-value for peeloff (#2578)

This avoids copies when used with std::move.
This commit is contained in:
Andrew Gaul 2024-10-29 18:21:07 +09:00 committed by GitHub
parent 3b226ed672
commit b87a8400e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 4 deletions

View File

@ -4406,7 +4406,7 @@ bool S3fsCurl::CopyMultipartPostComplete()
{
std::string etag;
partdata.uploaded = simple_parse_xml(bodydata.c_str(), bodydata.size(), "ETag", etag);
partdata.petag->etag = peeloff(etag);
partdata.petag->etag = peeloff(std::move(etag));
bodydata.clear();
headdata.clear();

View File

@ -125,12 +125,14 @@ std::string trim(std::string s, const char *t /* = SPACES */)
return trim_left(trim_right(std::move(s), t), t);
}
std::string peeloff(const std::string& s)
std::string peeloff(std::string s)
{
if(s.size() < 2 || *s.cbegin() != '"' || *s.rbegin() != '"'){
return s;
}
return s.substr(1, s.size() - 2);
s.erase(s.size() - 1);
s.erase(0, 1);
return s;
}
//

View File

@ -80,7 +80,7 @@ std::string trim_left(std::string s, const char *t = SPACES);
std::string trim_right(std::string s, const char *t = SPACES);
std::string trim(std::string s, const char *t = SPACES);
std::string lower(std::string s);
std::string peeloff(const std::string& s);
std::string peeloff(std::string s);
//
// Date string