Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:29:28

0001 //
0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // Official repository: https://github.com/boostorg/beast
0008 //
0009 
0010 #ifndef BOOST_BEAST_IMPL_STRING_IPP
0011 #define BOOST_BEAST_IMPL_STRING_IPP
0012 
0013 #include <boost/beast/core/string.hpp>
0014 #include <boost/beast/core/detail/string.hpp>
0015 
0016 #include <algorithm>
0017 
0018 namespace boost {
0019 namespace beast {
0020 
0021 bool
0022 iequals(
0023     beast::string_view lhs,
0024     beast::string_view rhs)
0025 {
0026     if(lhs.size() != rhs.size())
0027         return false;
0028     auto n  = lhs.size();
0029     auto p1 = lhs.data();
0030     auto p2 = rhs.data();
0031     // fast loop
0032     while(n--)
0033     {
0034         if(*p1++ != *p2++)
0035             goto slow;
0036     }
0037     return true;
0038 slow:
0039     --p1;
0040     --p2;
0041     do
0042     {
0043         if( detail::ascii_tolower(*p1++) !=
0044             detail::ascii_tolower(*p2++))
0045             return false;
0046     }
0047     while(n--);
0048     return true;
0049 }
0050 
0051 bool
0052 iless::operator()(
0053     string_view lhs,
0054     string_view rhs) const
0055 {
0056     using std::begin;
0057     using std::end;
0058     return std::lexicographical_compare(
0059         begin(lhs), end(lhs), begin(rhs), end(rhs),
0060         [](char c1, char c2)
0061         {
0062             return detail::ascii_tolower(c1) < detail::ascii_tolower(c2);
0063         }
0064     );
0065 }
0066 
0067 } // beast
0068 } // boost
0069 
0070 #endif