Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:59

0001 //
0002 // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.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/json
0008 //
0009 
0010 #ifndef BOOST_JSON_DETAIL_DIGEST_HPP
0011 #define BOOST_JSON_DETAIL_DIGEST_HPP
0012 
0013 namespace boost {
0014 namespace json {
0015 namespace detail {
0016 
0017 // Calculate salted digest of string
0018 template<class ForwardIterator>
0019 std::size_t
0020 digest(
0021     ForwardIterator b,
0022     ForwardIterator e,
0023     std::size_t salt) noexcept
0024 {
0025 #if BOOST_JSON_ARCH == 64
0026     std::uint64_t const prime = 0x100000001B3ULL;
0027     std::uint64_t hash  = 0xcbf29ce484222325ULL;
0028 #else
0029     std::uint32_t const prime = 0x01000193UL;
0030     std::uint32_t hash  = 0x811C9DC5UL;
0031 #endif
0032     hash += salt;
0033     for(; b != e; ++b)
0034         hash = (*b ^ hash) * prime;
0035     return hash;
0036 }
0037 
0038 } // detail
0039 } // namespace json
0040 } // namespace boost
0041 
0042 #endif