diff options
author | Mike Pall <mike> | 2020-06-23 03:06:45 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2020-06-23 03:06:45 +0200 |
commit | ff34b48ddd6f2b3bdd26d6088662a214ba6b0288 (patch) | |
tree | 5585ab1933d148b046061a1e061686aa09e63789 /src/lj_str.h | |
parent | a44f53acf53603e7d9b88352de035b1804be4e88 (diff) | |
download | luajit-ff34b48ddd6f2b3bdd26d6088662a214ba6b0288.tar.gz luajit-ff34b48ddd6f2b3bdd26d6088662a214ba6b0288.tar.bz2 luajit-ff34b48ddd6f2b3bdd26d6088662a214ba6b0288.zip |
Redesign and harden string interning.
Up to 40% faster on hash-intensive benchmarks.
With some ideas from Sokolov Yura.
Diffstat (limited to 'src/lj_str.h')
-rw-r--r-- | src/lj_str.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lj_str.h b/src/lj_str.h index 2e9bfc1d..01c6ba6b 100644 --- a/src/lj_str.h +++ b/src/lj_str.h | |||
@@ -20,8 +20,12 @@ LJ_FUNC int lj_str_haspattern(GCstr *s); | |||
20 | LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask); | 20 | LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask); |
21 | LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len); | 21 | LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len); |
22 | LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s); | 22 | LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s); |
23 | LJ_FUNC void LJ_FASTCALL lj_str_init(lua_State *L); | ||
24 | #define lj_str_freetab(g) \ | ||
25 | (lj_mem_freevec(g, g->str.tab, g->str.mask+1, GCRef)) | ||
23 | 26 | ||
24 | #define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s))) | 27 | #define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s))) |
25 | #define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1)) | 28 | #define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1)) |
29 | #define lj_str_size(len) (sizeof(GCstr) + (((len)+4) & ~(MSize)3)) | ||
26 | 30 | ||
27 | #endif | 31 | #endif |