diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-08 12:32:08 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-08 15:31:29 +1000 |
commit | 2977fe002407b6f86efa4ba5216f567082f33e45 (patch) | |
tree | da7e0127cd26534d01655e7b6a5c8732fb4920a0 /src/ltable.js | |
parent | 8c8585a0bba0e05b6382f2f4f063515b5988639c (diff) | |
download | fengari-2977fe002407b6f86efa4ba5216f567082f33e45.tar.gz fengari-2977fe002407b6f86efa4ba5216f567082f33e45.tar.bz2 fengari-2977fe002407b6f86efa4ba5216f567082f33e45.zip |
Move string functions to centralised lstring.js
Diffstat (limited to 'src/ltable.js')
-rw-r--r-- | src/ltable.js | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/ltable.js b/src/ltable.js index 428ee5e..de4c686 100644 --- a/src/ltable.js +++ b/src/ltable.js @@ -6,13 +6,9 @@ const assert = require('assert'); const defs = require('./defs.js'); const ldebug = require('./ldebug.js'); const lobject = require('./lobject.js'); +const lstring = require('./lstring.js'); const CT = defs.constant_types; -/* converts strings (arrays) to a consistent map key */ -const hashstr = function(str) { - return str.map(e => `${e}|`).join(''); -}; - const table_hash = function(key) { switch(key.type) { case CT.LUA_TBOOLEAN: @@ -28,7 +24,7 @@ const table_hash = function(key) { return key.value; case CT.LUA_TSHRSTR: case CT.LUA_TLNGSTR: - return hashstr(key.value); + return lstring.luaS_hash(key.value); default: throw new Error("unknown key type: " + key.type); } @@ -58,7 +54,7 @@ const luaH_getint = function(t, key) { const luaH_getstr = function(t, key) { assert(Array.isArray(key)); - return getgeneric(t, hashstr(key)); + return getgeneric(t, lstring.luaS_hash(key)); }; const luaH_get = function(t, key) { |