LCOV - code coverage report
Current view: top level - src/base - hashmap-entry.h (source / functions) Hit Total Coverage
Test: app.info Lines: 4 4 100.0 %
Date: 2019-04-17 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2016 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #ifndef V8_BASE_HASHMAP_ENTRY_H_
       6             : #define V8_BASE_HASHMAP_ENTRY_H_
       7             : 
       8             : #include <cstdint>
       9             : 
      10             : namespace v8 {
      11             : namespace base {
      12             : 
      13             : // HashMap entries are (key, value, hash) triplets, with a boolean indicating if
      14             : // they are an empty entry. Some clients may not need to use the value slot
      15             : // (e.g. implementers of sets, where the key is the value).
      16             : template <typename Key, typename Value>
      17             : struct TemplateHashMapEntry {
      18             :   Key key;
      19             :   Value value;
      20             :   uint32_t hash;  // The full hash value for key
      21             : 
      22             :   TemplateHashMapEntry(Key key, Value value, uint32_t hash)
      23   164089467 :       : key(key), value(value), hash(hash), exists_(true) {}
      24             : 
      25             :   bool exists() const { return exists_; }
      26             : 
      27   158630859 :   void clear() { exists_ = false; }
      28             : 
      29             :  private:
      30             :   bool exists_;
      31             : };
      32             : 
      33             : // Specialization for pointer-valued keys
      34             : template <typename Key, typename Value>
      35             : struct TemplateHashMapEntry<Key*, Value> {
      36             :   Key* key;
      37             :   Value value;
      38             :   uint32_t hash;  // The full hash value for key
      39             : 
      40             :   TemplateHashMapEntry(Key* key, Value value, uint32_t hash)
      41   312575288 :       : key(key), value(value), hash(hash) {}
      42             : 
      43             :   bool exists() const { return key != nullptr; }
      44             : 
      45   691854811 :   void clear() { key = nullptr; }
      46             : };
      47             : 
      48             : // TODO(leszeks): There could be a specialisation for void values (e.g. for
      49             : // sets), which omits the value field
      50             : 
      51             : }  // namespace base
      52             : }  // namespace v8
      53             : 
      54             : #endif  // V8_BASE_HASHMAP_ENTRY_H_

Generated by: LCOV version 1.10