Pass string_view by value

This commit is contained in:
Vinnie Falco
2017-07-12 16:35:52 -07:00
parent 32cd5e4082
commit b18d0d15b0
6 changed files with 24 additions and 18 deletions

View File

@@ -1,3 +1,9 @@
Version 81:
* Pass string_view by value
--------------------------------------------------------------------------------
Version 80: Version 80:
* Javadoc tidying * Javadoc tidying

View File

@@ -41,7 +41,7 @@ print(T const& t)
inline inline
void void
string_param:: string_param::
print(string_view const& sv) print(string_view sv)
{ {
sv_ = sv; sv_ = sv;
} }

View File

@@ -60,8 +60,8 @@ ascii_tolower(char c)
template<class = void> template<class = void>
bool bool
iequals( iequals(
beast::string_view const& lhs, beast::string_view lhs,
beast::string_view const& rhs) beast::string_view rhs)
{ {
auto n = lhs.size(); auto n = lhs.size();
if(rhs.size() != n) if(rhs.size() != n)
@@ -102,8 +102,8 @@ iequals(
inline inline
bool bool
iequals( iequals(
beast::string_view const& lhs, beast::string_view lhs,
beast::string_view const& rhs) beast::string_view rhs)
{ {
return detail::iequals(lhs, rhs); return detail::iequals(lhs, rhs);
} }
@@ -116,8 +116,8 @@ struct iless
{ {
bool bool
operator()( operator()(
string_view const& lhs, string_view lhs,
string_view const& rhs) const string_view rhs) const
{ {
using std::begin; using std::begin;
using std::end; using std::end;
@@ -139,8 +139,8 @@ struct iequal
{ {
bool bool
operator()( operator()(
string_view const& lhs, string_view lhs,
string_view const& rhs) const string_view rhs) const
{ {
return iequals(lhs, rhs); return iequals(lhs, rhs);
} }

View File

@@ -45,7 +45,7 @@ class string_param
print(T const&); print(T const&);
void void
print(string_view const&); print(string_view);
template<class T> template<class T>
typename std::enable_if< typename std::enable_if<

View File

@@ -28,7 +28,7 @@ struct field_table
struct hash struct hash
{ {
std::size_t std::size_t
operator()(string_view const& s) const operator()(string_view s) const
{ {
auto const n = s.size(); auto const n = s.size();
return return
@@ -43,8 +43,8 @@ struct field_table
// assumes inputs have equal length // assumes inputs have equal length
bool bool
operator()( operator()(
string_view const& lhs, string_view lhs,
string_view const& rhs) const string_view rhs) const
{ {
auto p1 = lhs.data(); auto p1 = lhs.data();
auto p2 = rhs.data(); auto p2 = rhs.data();

View File

@@ -737,7 +737,7 @@ template<class String, class Pred>
void void
filter_token_list( filter_token_list(
String& s, String& s,
string_view const& value, string_view value,
Pred&& pred) Pred&& pred)
{ {
token_list te{value}; token_list te{value};
@@ -764,7 +764,7 @@ template<class String, class Pred>
void void
filter_token_list_last( filter_token_list_last(
String& s, String& s,
string_view const& value, string_view value,
Pred&& pred) Pred&& pred)
{ {
token_list te{value}; token_list te{value};
@@ -801,7 +801,7 @@ filter_token_list_last(
template<class String> template<class String>
void void
keep_alive_impl( keep_alive_impl(
String& s, string_view const& value, String& s, string_view value,
unsigned version, bool keep_alive) unsigned version, bool keep_alive)
{ {
if(version < 11) if(version < 11)
@@ -1025,7 +1025,7 @@ set_chunked_impl(bool value)
{ {
static_string<max_static_buffer> buf; static_string<max_static_buffer> buf;
detail::filter_token_list_last(buf, it->value(), detail::filter_token_list_last(buf, it->value(),
[](string_view const& s) [](string_view s)
{ {
return iequals(s, "chunked"); return iequals(s, "chunked");
}); });
@@ -1050,7 +1050,7 @@ set_chunked_impl(bool value)
#endif #endif
s.reserve(it->value().size()); s.reserve(it->value().size());
detail::filter_token_list_last(s, it->value(), detail::filter_token_list_last(s, it->value(),
[](string_view const& s) [](string_view s)
{ {
return iequals(s, "chunked"); return iequals(s, "chunked");
}); });