Bug 1123151 (part 2) - Add PLDHashTable::IsInitialized(). r=froydnj.

This encapsulates most of the uses of PLDHashTable::ops.
This commit is contained in:
Nicholas Nethercote
2015-01-19 16:11:34 -08:00
parent 009293c72a
commit 4604f714c6
32 changed files with 153 additions and 140 deletions

View File

@@ -131,10 +131,10 @@ nsHTMLEntities::ReleaseTable(void)
if (--gTableRefCnt != 0)
return;
if (gEntityToUnicode.ops) {
if (gEntityToUnicode.IsInitialized()) {
PL_DHashTableFinish(&gEntityToUnicode);
}
if (gUnicodeToEntity.ops) {
if (gUnicodeToEntity.IsInitialized()) {
PL_DHashTableFinish(&gUnicodeToEntity);
}
}
@@ -142,8 +142,9 @@ nsHTMLEntities::ReleaseTable(void)
int32_t
nsHTMLEntities::EntityToUnicode(const nsCString& aEntity)
{
NS_ASSERTION(gEntityToUnicode.ops, "no lookup table, needs addref");
if (!gEntityToUnicode.ops)
NS_ASSERTION(gEntityToUnicode.IsInitialized(),
"no lookup table, needs addref");
if (!gEntityToUnicode.IsInitialized())
return -1;
//this little piece of code exists because entities may or may not have the terminating ';'.
@@ -180,7 +181,8 @@ nsHTMLEntities::EntityToUnicode(const nsAString& aEntity) {
const char*
nsHTMLEntities::UnicodeToEntity(int32_t aUnicode)
{
NS_ASSERTION(gUnicodeToEntity.ops, "no lookup table, needs addref");
NS_ASSERTION(gUnicodeToEntity.IsInitialized(),
"no lookup table, needs addref");
EntityNodeEntry* entry =
static_cast<EntityNodeEntry*>
(PL_DHashTableLookup(&gUnicodeToEntity, NS_INT32_TO_PTR(aUnicode)));