• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Abseil Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "absl/hash/internal/hash.h"
16 
17 namespace absl {
18 ABSL_NAMESPACE_BEGIN
19 namespace hash_internal {
20 
CombineLargeContiguousImpl32(uint64_t state,const unsigned char * first,size_t len)21 uint64_t CityHashState::CombineLargeContiguousImpl32(uint64_t state,
22                                                      const unsigned char* first,
23                                                      size_t len) {
24   while (len >= PiecewiseChunkSize()) {
25     state =
26         Mix(state, absl::hash_internal::CityHash32(reinterpret_cast<const char*>(first),
27                                          PiecewiseChunkSize()));
28     len -= PiecewiseChunkSize();
29     first += PiecewiseChunkSize();
30   }
31   // Handle the remainder.
32   return CombineContiguousImpl(state, first, len,
33                                std::integral_constant<int, 4>{});
34 }
35 
CombineLargeContiguousImpl64(uint64_t state,const unsigned char * first,size_t len)36 uint64_t CityHashState::CombineLargeContiguousImpl64(uint64_t state,
37                                                      const unsigned char* first,
38                                                      size_t len) {
39   while (len >= PiecewiseChunkSize()) {
40     state =
41         Mix(state, absl::hash_internal::CityHash64(reinterpret_cast<const char*>(first),
42                                          PiecewiseChunkSize()));
43     len -= PiecewiseChunkSize();
44     first += PiecewiseChunkSize();
45   }
46   // Handle the remainder.
47   return CombineContiguousImpl(state, first, len,
48                                std::integral_constant<int, 8>{});
49 }
50 
51 ABSL_CONST_INIT const void* const CityHashState::kSeed = &kSeed;
52 
53 }  // namespace hash_internal
54 ABSL_NAMESPACE_END
55 }  // namespace absl
56