Squid Web Cache
master
Loading...
Searching...
No Matches
Algorithms.cc
Go to the documentation of this file.
1
/*
2
* Copyright (C) 1996-2025 The Squid Software Foundation and contributors
3
*
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.
7
*/
8
9
#include "
squid.h
"
10
#include "
sbuf/Algorithms.h
"
11
12
// private common implementation for SBuf hash variants
13
static
std::size_t
14
SBufHashCommon_
(
const
SBuf
& sbuf,
bool
caseInsensitive
)
noexcept
15
{
16
//ripped and adapted from hash_string
17
const
char
*s = sbuf.rawContent();
18
size_t
rv = 0;
19
SBuf::size_type
len=sbuf.length();
20
while
(len != 0) {
21
rv ^= 271 * (
caseInsensitive
?
xtolower
(*s) : *s);
22
++s;
23
--len;
24
}
25
return
rv ^ (sbuf.length() * 271);
26
}
27
28
std::size_t
29
std::hash<SBuf>::operator() (
const
SBuf
& sbuf)
const
noexcept
30
{
31
return
SBufHashCommon_
(sbuf,
false
);
32
}
33
34
std::size_t
35
CaseInsensitiveSBufHash::operator()
(
const
SBuf
& sbuf)
const
noexcept
36
{
37
return
SBufHashCommon_
(sbuf,
true
);
38
}
39
SBufHashCommon_
static std::size_t SBufHashCommon_(const SBuf &sbuf, bool caseInsensitive) noexcept
Definition
Algorithms.cc:14
Algorithms.h
caseInsensitive
@ caseInsensitive
Definition
SBuf.h:38
CaseInsensitiveSBufHash::operator()
std::size_t operator()(const SBuf &) const noexcept
Definition
Algorithms.cc:35
SBuf
Definition
SBuf.h:94
SBuf::size_type
MemBlob::size_type size_type
Definition
SBuf.h:96
squid.h
xtolower
#define xtolower(x)
Definition
xis.h:17
squid
src
sbuf
Algorithms.cc
Generated by
1.9.8