]> git.ipfire.org Git - thirdparty/squid.git/blame - src/SBufAlgos.cc
Moved std::hash<SBuf> from SBuf.h to SBufAlgos.h
[thirdparty/squid.git] / src / SBufAlgos.cc
CommitLineData
25436c30
FC
1/*
2 * Copyright (C) 1996-2015 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 "SBufAlgos.h"
11
12std::size_t std::hash<SBuf>::operator() (const SBuf & sbuf) const noexcept
13{
14 //ripped and adapted from hash_string
15 const char *s = sbuf.rawContent();
16 size_t rv = 0;
17 SBuf::size_type len=sbuf.length();
18 while (len != 0) {
19 rv ^= 271 * *s;
20 ++s;
21 --len;
22 }
23 return rv ^ (sbuf.length() * 271);
24}