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/. */
5 #include "nsHtml5AtomTable.h"
6 #include "nsThreadUtils.h"
8 nsHtml5AtomTable::nsHtml5AtomTable() : mRecentlyUsedParserAtoms
{} {
10 mPermittedLookupEventTarget
= mozilla::GetCurrentSerialEventTarget();
14 nsHtml5AtomTable::~nsHtml5AtomTable() {}
16 nsAtom
* nsHtml5AtomTable::GetAtom(const nsAString
& aKey
) {
18 MOZ_ASSERT(mPermittedLookupEventTarget
->IsOnCurrentThread());
21 uint32_t index
= mozilla::HashString(aKey
) % RECENTLY_USED_PARSER_ATOMS_SIZE
;
22 if (nsAtom
* atom
= mRecentlyUsedParserAtoms
[index
]) {
23 if (atom
->Equals(aKey
)) {
28 RefPtr
<nsAtom
> atom
= NS_Atomize(aKey
);
29 nsAtom
* ret
= atom
.get();
30 mRecentlyUsedParserAtoms
[index
] = std::move(atom
);