зеркало из https://github.com/mozilla/pjs.git
Micro-optimize source (compilers probably do it, but hey); fix a comment.
This commit is contained in:
Родитель
859bcd8cc5
Коммит
dd89a16a61
|
@ -370,7 +370,7 @@ js_AtomizeHashedKey(JSContext *cx, jsval key, JSHashNumber keyHash, uintN flags)
|
||||||
JSAtom *atom;
|
JSAtom *atom;
|
||||||
|
|
||||||
state = &cx->runtime->atomState;
|
state = &cx->runtime->atomState;
|
||||||
JS_LOCK(&state->lock,cx);
|
JS_LOCK(&state->lock, cx);
|
||||||
table = state->table;
|
table = state->table;
|
||||||
hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
|
hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
|
||||||
if ((he = *hep) == NULL) {
|
if ((he = *hep) == NULL) {
|
||||||
|
@ -444,7 +444,7 @@ js_AtomizeDouble(JSContext *cx, jsdouble d, uintN flags)
|
||||||
keyHash = HASH_DOUBLE(dp);
|
keyHash = HASH_DOUBLE(dp);
|
||||||
key = DOUBLE_TO_JSVAL(dp);
|
key = DOUBLE_TO_JSVAL(dp);
|
||||||
state = &cx->runtime->atomState;
|
state = &cx->runtime->atomState;
|
||||||
JS_LOCK(&state->lock,cx);
|
JS_LOCK(&state->lock, cx);
|
||||||
table = state->table;
|
table = state->table;
|
||||||
hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
|
hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
|
||||||
if ((he = *hep) == NULL) {
|
if ((he = *hep) == NULL) {
|
||||||
|
@ -454,7 +454,7 @@ js_AtomizeDouble(JSContext *cx, jsdouble d, uintN flags)
|
||||||
JS_UNLOCK(&state->lock,cx);
|
JS_UNLOCK(&state->lock,cx);
|
||||||
if (!js_NewDoubleValue(cx, d, &key))
|
if (!js_NewDoubleValue(cx, d, &key))
|
||||||
return NULL;
|
return NULL;
|
||||||
JS_LOCK(&state->lock,cx);
|
JS_LOCK(&state->lock, cx);
|
||||||
#ifdef JS_THREADSAFE
|
#ifdef JS_THREADSAFE
|
||||||
if (state->tablegen != gen) {
|
if (state->tablegen != gen) {
|
||||||
hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
|
hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
|
||||||
|
@ -492,7 +492,7 @@ js_AtomizeString(JSContext *cx, JSString *str, uintN flags)
|
||||||
keyHash = js_HashString(str);
|
keyHash = js_HashString(str);
|
||||||
key = STRING_TO_JSVAL(str);
|
key = STRING_TO_JSVAL(str);
|
||||||
state = &cx->runtime->atomState;
|
state = &cx->runtime->atomState;
|
||||||
JS_LOCK(&state->lock,cx);
|
JS_LOCK(&state->lock, cx);
|
||||||
table = state->table;
|
table = state->table;
|
||||||
hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
|
hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
|
||||||
if ((he = *hep) == NULL) {
|
if ((he = *hep) == NULL) {
|
||||||
|
@ -500,16 +500,13 @@ js_AtomizeString(JSContext *cx, JSString *str, uintN flags)
|
||||||
#ifdef JS_THREADSAFE
|
#ifdef JS_THREADSAFE
|
||||||
uint32 gen = state->tablegen;
|
uint32 gen = state->tablegen;
|
||||||
#endif
|
#endif
|
||||||
JS_UNLOCK(&state->lock,cx);
|
JS_UNLOCK(&state->lock, cx);
|
||||||
if (flags & ATOM_NOCOPY) {
|
str = ((flags & ATOM_NOCOPY) ? js_NewString : js_NewStringCopyN)
|
||||||
str = js_NewString(cx, str->chars, str->length, 0);
|
(cx, str->chars, str->length, 0);
|
||||||
} else {
|
|
||||||
str = js_NewStringCopyN(cx, str->chars, str->length, 0);
|
|
||||||
}
|
|
||||||
if (!str)
|
if (!str)
|
||||||
return NULL;
|
return NULL;
|
||||||
key = STRING_TO_JSVAL(str);
|
key = STRING_TO_JSVAL(str);
|
||||||
JS_LOCK(&state->lock,cx);
|
JS_LOCK(&state->lock, cx);
|
||||||
#ifdef JS_THREADSAFE
|
#ifdef JS_THREADSAFE
|
||||||
if (state->tablegen != gen) {
|
if (state->tablegen != gen) {
|
||||||
hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
|
hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
|
||||||
|
@ -548,7 +545,7 @@ js_Atomize(JSContext *cx, const char *bytes, size_t length, uintN flags)
|
||||||
/*
|
/*
|
||||||
* Avoiding the malloc in js_InflateString on shorter strings saves us
|
* Avoiding the malloc in js_InflateString on shorter strings saves us
|
||||||
* over 20,000 malloc calls on mozilla browser startup. This compares to
|
* over 20,000 malloc calls on mozilla browser startup. This compares to
|
||||||
* only 131 calls where the string is longer than a 32 char buffer.
|
* only 131 calls where the string is longer than a 31 char (net) buffer.
|
||||||
* The vast majority of atomized strings are already in the hashtable. So
|
* The vast majority of atomized strings are already in the hashtable. So
|
||||||
* js_AtomizeString rarely has to copy the temp string we make.
|
* js_AtomizeString rarely has to copy the temp string we make.
|
||||||
*/
|
*/
|
||||||
|
|
Загрузка…
Ссылка в новой задаче