Bug 723346 - Make sharpObjectMap a modern HashMap; r=Waldo

This is the last user of the old-style C hashtables in the JS engine.
This commit is contained in:
Terrence Cole
2012-02-15 17:55:25 -08:00
parent e4ac08e990
commit 989ba317e5
5 changed files with 79 additions and 103 deletions

View File

@@ -1434,23 +1434,22 @@ JSObject::makeDenseArraySlow(JSContext *cx)
class ArraySharpDetector
{
JSContext *cx;
JSHashEntry *he;
bool success;
bool alreadySeen;
bool sharp;
public:
ArraySharpDetector(JSContext *cx)
: cx(cx),
he(NULL),
success(false),
alreadySeen(false),
sharp(false)
{}
bool init(JSObject *obj) {
he = js_EnterSharpObject(cx, obj, NULL, &alreadySeen);
if (!he)
success = js_EnterSharpObject(cx, obj, NULL, &alreadySeen, &sharp);
if (!success)
return false;
sharp = IS_SHARP(he);
return true;
}
@@ -1460,7 +1459,7 @@ class ArraySharpDetector
}
~ArraySharpDetector() {
if (he && !sharp)
if (success && !sharp)
js_LeaveSharpObject(cx, NULL);
}
};