зеркало из https://github.com/mozilla/pjs.git
Consolidate duplicated code into the beginning of the double-hashing loop. b=374906 r=brendan
This commit is contained in:
Родитель
1135ea0c8f
Коммит
1554843a32
|
@ -424,15 +424,17 @@ SearchTable(JSDHashTable *table, const void *key, JSDHashNumber keyHash,
|
|||
sizeMask = JS_BITMASK(sizeLog2);
|
||||
|
||||
/* Save the first removed entry pointer so JS_DHASH_ADD can recycle it. */
|
||||
if (ENTRY_IS_REMOVED(entry)) {
|
||||
firstRemoved = entry;
|
||||
} else {
|
||||
firstRemoved = NULL;
|
||||
if (op == JS_DHASH_ADD)
|
||||
entry->keyHash |= COLLISION_FLAG;
|
||||
}
|
||||
firstRemoved = NULL;
|
||||
|
||||
for (;;) {
|
||||
if (JS_UNLIKELY(ENTRY_IS_REMOVED(entry))) {
|
||||
if (!firstRemoved)
|
||||
firstRemoved = entry;
|
||||
} else {
|
||||
if (op == JS_DHASH_ADD)
|
||||
entry->keyHash |= COLLISION_FLAG;
|
||||
}
|
||||
|
||||
METER(table->stats.steps++);
|
||||
hash1 -= hash2;
|
||||
hash1 &= sizeMask;
|
||||
|
@ -448,14 +450,6 @@ SearchTable(JSDHashTable *table, const void *key, JSDHashNumber keyHash,
|
|||
METER(table->stats.hits++);
|
||||
return entry;
|
||||
}
|
||||
|
||||
if (ENTRY_IS_REMOVED(entry)) {
|
||||
if (!firstRemoved)
|
||||
firstRemoved = entry;
|
||||
} else {
|
||||
if (op == JS_DHASH_ADD)
|
||||
entry->keyHash |= COLLISION_FLAG;
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTREACHED */
|
||||
|
@ -499,10 +493,10 @@ FindFreeEntry(JSDHashTable *table, JSDHashNumber keyHash)
|
|||
hash2 = HASH2(keyHash, sizeLog2, hashShift);
|
||||
sizeMask = JS_BITMASK(sizeLog2);
|
||||
|
||||
JS_ASSERT(!ENTRY_IS_REMOVED(entry));
|
||||
entry->keyHash |= COLLISION_FLAG;
|
||||
|
||||
for (;;) {
|
||||
JS_ASSERT(!ENTRY_IS_REMOVED(entry));
|
||||
entry->keyHash |= COLLISION_FLAG;
|
||||
|
||||
METER(table->stats.steps++);
|
||||
hash1 -= hash2;
|
||||
hash1 &= sizeMask;
|
||||
|
@ -512,9 +506,6 @@ FindFreeEntry(JSDHashTable *table, JSDHashNumber keyHash)
|
|||
METER(table->stats.misses++);
|
||||
return entry;
|
||||
}
|
||||
|
||||
JS_ASSERT(!ENTRY_IS_REMOVED(entry));
|
||||
entry->keyHash |= COLLISION_FLAG;
|
||||
}
|
||||
|
||||
/* NOTREACHED */
|
||||
|
|
|
@ -30,5 +30,7 @@ s/JS_STATIC_DLL_CALLBACK/PR_STATIC_CALLBACK/
|
|||
s/JS_NewDHashTable/PL_NewDHashTable/
|
||||
s/JS_ASSERT(0)/NS_NOTREACHED("0")/
|
||||
s/\( *\)JS_ASSERT(\(.*\));/\1NS_ASSERTION(\2,\n\1 "\2");/
|
||||
s/JS_UNLIKELY/NS_UNLIKELY/g
|
||||
s/JS_LIKELY/NS_LIKELY/g
|
||||
s/JS_/PR_/g
|
||||
s/fprintf(stderr,/printf_stderr(/
|
||||
|
|
|
@ -430,15 +430,17 @@ SearchTable(PLDHashTable *table, const void *key, PLDHashNumber keyHash,
|
|||
sizeMask = PR_BITMASK(sizeLog2);
|
||||
|
||||
/* Save the first removed entry pointer so PL_DHASH_ADD can recycle it. */
|
||||
if (ENTRY_IS_REMOVED(entry)) {
|
||||
firstRemoved = entry;
|
||||
} else {
|
||||
firstRemoved = NULL;
|
||||
if (op == PL_DHASH_ADD)
|
||||
entry->keyHash |= COLLISION_FLAG;
|
||||
}
|
||||
firstRemoved = NULL;
|
||||
|
||||
for (;;) {
|
||||
if (NS_UNLIKELY(ENTRY_IS_REMOVED(entry))) {
|
||||
if (!firstRemoved)
|
||||
firstRemoved = entry;
|
||||
} else {
|
||||
if (op == PL_DHASH_ADD)
|
||||
entry->keyHash |= COLLISION_FLAG;
|
||||
}
|
||||
|
||||
METER(table->stats.steps++);
|
||||
hash1 -= hash2;
|
||||
hash1 &= sizeMask;
|
||||
|
@ -454,14 +456,6 @@ SearchTable(PLDHashTable *table, const void *key, PLDHashNumber keyHash,
|
|||
METER(table->stats.hits++);
|
||||
return entry;
|
||||
}
|
||||
|
||||
if (ENTRY_IS_REMOVED(entry)) {
|
||||
if (!firstRemoved)
|
||||
firstRemoved = entry;
|
||||
} else {
|
||||
if (op == PL_DHASH_ADD)
|
||||
entry->keyHash |= COLLISION_FLAG;
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTREACHED */
|
||||
|
@ -506,11 +500,11 @@ FindFreeEntry(PLDHashTable *table, PLDHashNumber keyHash)
|
|||
hash2 = HASH2(keyHash, sizeLog2, hashShift);
|
||||
sizeMask = PR_BITMASK(sizeLog2);
|
||||
|
||||
NS_ASSERTION(!ENTRY_IS_REMOVED(entry),
|
||||
"!ENTRY_IS_REMOVED(entry)");
|
||||
entry->keyHash |= COLLISION_FLAG;
|
||||
|
||||
for (;;) {
|
||||
NS_ASSERTION(!ENTRY_IS_REMOVED(entry),
|
||||
"!ENTRY_IS_REMOVED(entry)");
|
||||
entry->keyHash |= COLLISION_FLAG;
|
||||
|
||||
METER(table->stats.steps++);
|
||||
hash1 -= hash2;
|
||||
hash1 &= sizeMask;
|
||||
|
@ -520,10 +514,6 @@ FindFreeEntry(PLDHashTable *table, PLDHashNumber keyHash)
|
|||
METER(table->stats.misses++);
|
||||
return entry;
|
||||
}
|
||||
|
||||
NS_ASSERTION(!ENTRY_IS_REMOVED(entry),
|
||||
"!ENTRY_IS_REMOVED(entry)");
|
||||
entry->keyHash |= COLLISION_FLAG;
|
||||
}
|
||||
|
||||
/* NOTREACHED */
|
||||
|
|
Загрузка…
Ссылка в новой задаче