unquote takes s by reference.

Closes #471.
This commit is contained in:
Klemens Morgenstern
2022-10-12 02:00:25 +08:00
committed by Klemens Morgenstern
parent 8f74e0d464
commit 1a02413638
2 changed files with 6 additions and 8 deletions

View File

@@ -88,8 +88,8 @@ private:
BOOST_BEAST_DECL BOOST_BEAST_DECL
static static
std::string void
unquote(string_view sr); unquote(string_view sr, std::string & s);
BOOST_BEAST_DECL BOOST_BEAST_DECL
void void

View File

@@ -18,11 +18,10 @@ namespace beast {
namespace http { namespace http {
std::string void param_list::const_iterator::
param_list::const_iterator:: unquote(string_view sr, std::string &s)
unquote(string_view sr)
{ {
std::string s; s.clear();
s.reserve(sr.size()); s.reserve(sr.size());
auto it = sr.begin() + 1; auto it = sr.begin() + 1;
auto end = sr.end() - 1; auto end = sr.end() - 1;
@@ -33,7 +32,6 @@ unquote(string_view sr)
s.push_back(*it); s.push_back(*it);
++it; ++it;
} }
return s;
} }
void void
@@ -50,7 +48,7 @@ increment()
else if(! pi_.v.second.empty() && else if(! pi_.v.second.empty() &&
pi_.v.second.front() == '"') pi_.v.second.front() == '"')
{ {
s_ = unquote(pi_.v.second); unquote(pi_.v.second, s_);
pi_.v.second = string_view{ pi_.v.second = string_view{
s_.data(), s_.size()}; s_.data(), s_.size()};
} }