]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/sbuf/Algorithms.cc
2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 #include "sbuf/Algorithms.h"
12 // private common implementation for SBuf hash variants
14 SBufHashCommon_ (const SBuf
& sbuf
, bool caseInsensitive
) noexcept
16 //ripped and adapted from hash_string
17 const char *s
= sbuf
.rawContent();
19 SBuf::size_type len
=sbuf
.length();
21 rv
^= 271 * (caseInsensitive
? xtolower(*s
) : *s
);
25 return rv
^ (sbuf
.length() * 271);
29 std::hash
<SBuf
>::operator() (const SBuf
& sbuf
) const noexcept
31 return SBufHashCommon_(sbuf
, false);
35 CaseInsensitiveSBufHash::operator() (const SBuf
& sbuf
) const noexcept
37 return SBufHashCommon_(sbuf
, true);