Coverage Report

Created: 2025-12-31 08:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ninja/src/hash_map.h
Line
Count
Source
1
// Copyright 2011 Google Inc. All Rights Reserved.
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
//     http://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
#ifndef NINJA_MAP_H_
16
#define NINJA_MAP_H_
17
18
#include <algorithm>
19
#include <string.h>
20
#include "string_piece.h"
21
#include "util.h"
22
23
#include "third_party/emhash/hash_table8.hpp"
24
#include "third_party/rapidhash/rapidhash.h"
25
26
namespace std {
27
template<>
28
struct hash<StringPiece> {
29
  typedef StringPiece argument_type;
30
  typedef size_t result_type;
31
32
2.64M
  size_t operator()(StringPiece key) const {
33
2.64M
    return rapidhash(key.str_, key.len_);
34
2.64M
  }
35
};
36
}
37
38
/// A template for hash_maps keyed by a StringPiece whose string is
39
/// owned externally (typically by the values).  Use like:
40
/// ExternalStringHash<Foo*>::Type foos; to make foos into a hash
41
/// mapping StringPiece => Foo*.
42
template<typename V>
43
struct ExternalStringHashMap {
44
  typedef emhash8::HashMap<StringPiece, V> Type;
45
};
46
47
#endif // NINJA_MAP_H_