/src/boost/boost/json/detail/digest.hpp
Line | Count | Source |
1 | | // |
2 | | // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) |
3 | | // |
4 | | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
5 | | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
6 | | // |
7 | | // Official repository: https://github.com/boostorg/json |
8 | | // |
9 | | |
10 | | #ifndef BOOST_JSON_DETAIL_DIGEST_HPP |
11 | | #define BOOST_JSON_DETAIL_DIGEST_HPP |
12 | | |
13 | | namespace boost { |
14 | | namespace json { |
15 | | namespace detail { |
16 | | |
17 | | // Calculate salted digest of string |
18 | | template<class ForwardIterator> |
19 | | std::size_t |
20 | | digest( |
21 | | ForwardIterator b, |
22 | | ForwardIterator e, |
23 | | std::size_t salt) noexcept |
24 | 1.00M | { |
25 | 1.00M | #if BOOST_JSON_ARCH == 64 |
26 | 1.00M | std::uint64_t const prime = 0x100000001B3ULL; |
27 | 1.00M | std::uint64_t hash = 0xcbf29ce484222325ULL; |
28 | | #else |
29 | | std::uint32_t const prime = 0x01000193UL; |
30 | | std::uint32_t hash = 0x811C9DC5UL; |
31 | | #endif |
32 | 1.00M | hash += salt; |
33 | 9.87M | for(; b != e; ++b) |
34 | 8.87M | hash = (*b ^ hash) * prime; |
35 | 1.00M | return hash; |
36 | 1.00M | } unsigned long boost::json::detail::digest<char const*>(char const*, char const*, unsigned long) Line | Count | Source | 24 | 1.00M | { | 25 | 1.00M | #if BOOST_JSON_ARCH == 64 | 26 | 1.00M | std::uint64_t const prime = 0x100000001B3ULL; | 27 | 1.00M | std::uint64_t hash = 0xcbf29ce484222325ULL; | 28 | | #else | 29 | | std::uint32_t const prime = 0x01000193UL; | 30 | | std::uint32_t hash = 0x811C9DC5UL; | 31 | | #endif | 32 | 1.00M | hash += salt; | 33 | 9.87M | for(; b != e; ++b) | 34 | 8.87M | hash = (*b ^ hash) * prime; | 35 | 1.00M | return hash; | 36 | 1.00M | } |
Unexecuted instantiation: unsigned long boost::json::detail::digest<boost::json::detail::pointer_token::iterator>(boost::json::detail::pointer_token::iterator, boost::json::detail::pointer_token::iterator, unsigned long) |
37 | | |
38 | | } // detail |
39 | | } // namespace json |
40 | | } // namespace boost |
41 | | |
42 | | #endif |