2012-05-29 19:52:43 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-09-18 19:13:10 +04:00
|
|
|
|
|
|
|
#include "nsHtml5AtomTable.h"
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
|
|
|
|
nsHtml5AtomTable::nsHtml5AtomTable() : mRecentlyUsedParserAtoms{} {
|
|
|
|
#ifdef DEBUG
|
2020-06-23 08:05:36 +03:00
|
|
|
mPermittedLookupEventTarget = mozilla::GetCurrentSerialEventTarget();
|
2009-09-18 19:13:10 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-03-16 18:26:06 +03:00
|
|
|
nsHtml5AtomTable::~nsHtml5AtomTable() {}
|
2009-09-18 19:13:10 +04:00
|
|
|
|
|
|
|
nsAtom* nsHtml5AtomTable::GetAtom(const nsAString& aKey) {
|
|
|
|
#ifdef DEBUG
|
2018-11-09 16:27:10 +03:00
|
|
|
MOZ_ASSERT(mPermittedLookupEventTarget->IsOnCurrentThread());
|
2009-09-18 19:13:10 +04:00
|
|
|
#endif
|
2017-04-03 13:12:05 +03:00
|
|
|
|
|
|
|
uint32_t index = mozilla::HashString(aKey) % RECENTLY_USED_PARSER_ATOMS_SIZE;
|
2018-11-09 16:27:10 +03:00
|
|
|
if (nsAtom* atom = mRecentlyUsedParserAtoms[index]) {
|
|
|
|
if (atom->Equals(aKey)) {
|
|
|
|
return atom;
|
|
|
|
}
|
2009-09-18 19:13:10 +04:00
|
|
|
}
|
2017-04-03 13:12:05 +03:00
|
|
|
|
2018-11-09 16:27:10 +03:00
|
|
|
RefPtr<nsAtom> atom = NS_Atomize(aKey);
|
|
|
|
nsAtom* ret = atom.get();
|
2020-02-13 17:38:48 +03:00
|
|
|
mRecentlyUsedParserAtoms[index] = std::move(atom);
|
2018-11-09 16:27:10 +03:00
|
|
|
return ret;
|
2009-09-18 19:13:10 +04:00
|
|
|
}
|