Optimize field lookups

This commit is contained in:
Vinnie Falco committed 2017-07-20 08:15:29 -07:00
1 parent 64ff766b23
commit 2d6859831c
5 files changed
+205 -295

No files matched your search

+22 -7
View File
@@ -67,9 +67,24 @@ iequals(
return false;
auto p1 = lhs.data();
auto p2 = rhs.data();
char a, b;
while(n--)
if(ascii_tolower(*p1) != ascii_tolower(*p2))
{
a = *p1++;
b = *p2++;
if(a != b)
goto slow;
}
return true;
while(n--)
{
slow:
if(ascii_tolower(a) != ascii_tolower(b))
return false;
a = *p1++;
b = *p2++;
}
return true;
}
@@ -92,7 +107,7 @@ iequals(
return detail::iequals(lhs, rhs);
}
/** A strictly less predicate for strings, using a case-insensitive comparison.
/** A case-insensitive less predicate for strings.
The case-comparison operation is defined only for low-ASCII characters.
*/
@@ -100,8 +115,8 @@ struct iless
{
bool
operator()(
beast::string_view const& lhs,
beast::string_view const& rhs) const
string_view const& lhs,
string_view const& rhs) const
{
using std::begin;
using std::end;
@@ -115,7 +130,7 @@ struct iless
}
};
/** A predicate for string equality, using a case-insensitive comparison.
/** A case-insensitive equality predicate for strings.
The case-comparison operation is defined only for low-ASCII characters.
*/
@@ -123,8 +138,8 @@ struct iequal
{
bool
operator()(
beast::string_view const& lhs,
beast::string_view const& rhs) const
string_view const& lhs,
string_view const& rhs) const
{
return iequals(lhs, rhs);
}