mirror of
https://github.com/boostorg/beast.git
synced 2025-08-03 06:44:39 +02:00
Reduce the number of instantiations of filter_token_list
Not using lambdas in this case reduced the number of instantiations of the algorithm by a factor of 4x at no (observable) runtime cost. Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
Version 259:
|
||||
|
||||
* Reduce the number of instantiations of filter_token_list
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Version 258:
|
||||
|
||||
* Fix separate compilation in CI
|
||||
|
@@ -824,16 +824,23 @@ keep_alive_impl(
|
||||
String& s, string_view value,
|
||||
unsigned version, bool keep_alive)
|
||||
{
|
||||
struct iequals_predicate
|
||||
{
|
||||
bool operator()(string_view s)
|
||||
{
|
||||
return beast::iequals(s, sv1) || beast::iequals(s, sv2);
|
||||
}
|
||||
|
||||
string_view sv1;
|
||||
string_view sv2;
|
||||
};
|
||||
|
||||
if(version < 11)
|
||||
{
|
||||
if(keep_alive)
|
||||
{
|
||||
// remove close
|
||||
filter_token_list(s, value,
|
||||
[](string_view s)
|
||||
{
|
||||
return iequals(s, "close");
|
||||
});
|
||||
filter_token_list(s, value, iequals_predicate{"close"});
|
||||
// add keep-alive
|
||||
if(s.empty())
|
||||
s.append("keep-alive");
|
||||
@@ -844,12 +851,7 @@ keep_alive_impl(
|
||||
{
|
||||
// remove close and keep-alive
|
||||
filter_token_list(s, value,
|
||||
[](string_view s)
|
||||
{
|
||||
return
|
||||
iequals(s, "close") ||
|
||||
iequals(s, "keep-alive");
|
||||
});
|
||||
iequals_predicate{"close", "keep-alive"});
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -858,21 +860,12 @@ keep_alive_impl(
|
||||
{
|
||||
// remove close and keep-alive
|
||||
filter_token_list(s, value,
|
||||
[](string_view s)
|
||||
{
|
||||
return
|
||||
iequals(s, "close") ||
|
||||
iequals(s, "keep-alive");
|
||||
});
|
||||
iequals_predicate{"close", "keep-alive"});
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove keep-alive
|
||||
filter_token_list(s, value,
|
||||
[](string_view s)
|
||||
{
|
||||
return iequals(s, "keep-alive");
|
||||
});
|
||||
filter_token_list(s, value, iequals_predicate{"keep-alive"});
|
||||
// add close
|
||||
if(s.empty())
|
||||
s.append("close");
|
||||
|
Reference in New Issue
Block a user