StaticAtomSet.h (839B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef mozilla_dom_StaticAtomSet_h 6 #define mozilla_dom_StaticAtomSet_h 7 8 #include "nsAtom.h" 9 #include "nsTHashSet.h" 10 11 namespace mozilla::dom { 12 13 class StaticAtomSet : public nsTHashSet<const nsStaticAtom*> { 14 public: 15 StaticAtomSet() = default; 16 explicit StaticAtomSet(uint32_t aLength) 17 : nsTHashSet<const nsStaticAtom*>(aLength) {} 18 19 bool Contains(nsAtom* aAtom) { 20 // Because this set only contains static atoms, if aAtom isn't 21 // static we can immediately return false. 22 return aAtom->IsStatic() && GetEntry(aAtom->AsStatic()); 23 } 24 }; 25 26 } // namespace mozilla::dom 27 28 #endif // ifndef mozilla_dom_StaticAtomSet_h