tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TaggedParserAtomIndexHasher.h (1293B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 * vim: set ts=8 sts=2 et sw=2 tw=80:
      3 * This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef frontend_TaggedParserAtomIndexHasher_h
      8 #define frontend_TaggedParserAtomIndexHasher_h
      9 
     10 #include "frontend/ParserAtom.h"  // TaggedParserAtomIndex, TrivialTaggedParserAtomIndex
     11 #include "js/HashTable.h"  // HashNumber
     12 
     13 namespace js {
     14 namespace frontend {
     15 
     16 class TaggedParserAtomIndexHasher {
     17 public:
     18  using Lookup = TaggedParserAtomIndex;
     19 
     20  static inline HashNumber hash(const Lookup& l) {
     21    return HashNumber(l.rawData());
     22  }
     23  static inline bool match(TaggedParserAtomIndex entry, const Lookup& l) {
     24    return l == entry;
     25  }
     26 };
     27 
     28 class TrivialTaggedParserAtomIndexHasher {
     29 public:
     30  using Lookup = TrivialTaggedParserAtomIndex;
     31 
     32  static inline HashNumber hash(const Lookup& l) {
     33    return HashNumber(l.rawData());
     34  }
     35  static inline bool match(TrivialTaggedParserAtomIndex entry,
     36                           const Lookup& l) {
     37    return l == entry;
     38  }
     39 };
     40 
     41 }  // namespace frontend
     42 }  // namespace js
     43 
     44 #endif  // frontend_TaggedParserAtomIndexHasher_h