mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-08 15:34:09 +00:00
strings: compare hash as well
This commit is contained in:
parent
01e4754962
commit
33af3ea00e
@ -152,7 +152,7 @@ GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx)
|
|||||||
if (LJ_LIKELY((((uintptr_t)str+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4)) {
|
if (LJ_LIKELY((((uintptr_t)str+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4)) {
|
||||||
while (o != NULL) {
|
while (o != NULL) {
|
||||||
GCstr *sx = gco2str(o);
|
GCstr *sx = gco2str(o);
|
||||||
if (sx->len == len && str_fastcmp(str, strdata(sx), len) == 0) {
|
if (sx->hash == h && sx->len == len && str_fastcmp(str, strdata(sx), len) == 0) {
|
||||||
/* Resurrect if dead. Can only happen with fixstring() (keywords). */
|
/* Resurrect if dead. Can only happen with fixstring() (keywords). */
|
||||||
if (isdead(g, o)) flipwhite(o);
|
if (isdead(g, o)) flipwhite(o);
|
||||||
return sx; /* Return existing string. */
|
return sx; /* Return existing string. */
|
||||||
@ -162,7 +162,7 @@ GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx)
|
|||||||
} else { /* Slow path: end of string is too close to a page boundary. */
|
} else { /* Slow path: end of string is too close to a page boundary. */
|
||||||
while (o != NULL) {
|
while (o != NULL) {
|
||||||
GCstr *sx = gco2str(o);
|
GCstr *sx = gco2str(o);
|
||||||
if (sx->len == len && memcmp(str, strdata(sx), len) == 0) {
|
if (sx->hash == h && sx->len == len && memcmp(str, strdata(sx), len) == 0) {
|
||||||
/* Resurrect if dead. Can only happen with fixstring() (keywords). */
|
/* Resurrect if dead. Can only happen with fixstring() (keywords). */
|
||||||
if (isdead(g, o)) flipwhite(o);
|
if (isdead(g, o)) flipwhite(o);
|
||||||
return sx; /* Return existing string. */
|
return sx; /* Return existing string. */
|
||||||
|
Loading…
Reference in New Issue
Block a user