From ff74b65b59b5c463fa55bc37acf12cd95fcc1ee6 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Mon, 13 Mar 2017 10:18:31 +0100 Subject: No interning for now G.strt would have grown with each string --- README.md | 3 +-- src/lstate.js | 11 +++++++---- src/ltable.js | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index dffa1ec..042f2b2 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,11 @@ - [x] table - [ ] weak table - [x] function - - [ ] string (8-bit clean) + - [x] string (8-bit clean) - [ ] number (32-bit ?) - [ ] integer - [ ] float - [ ] userdata - - [ ] thread - [x] Tag Methods - [ ] C API - [x] lua_absindex diff --git a/src/lstate.js b/src/lstate.js index 519abde..99992c5 100644 --- a/src/lstate.js +++ b/src/lstate.js @@ -78,12 +78,15 @@ class global_State { } intern(stringArray) { - let key = stringArray.map(e => `${e}|`).join(''); + // TODO: when weak value maps are available + // let key = stringArray.map(e => `${e}|`).join(''); - if (!this.strt.has(key)) - this.strt.set(key, new lobject.TValue(CT.LUA_TLNGSTR, stringArray)); + // if (!this.strt.has(key)) + // this.strt.set(key, new lobject.TValue(CT.LUA_TLNGSTR, stringArray)); - return this.strt.get(key); + // return this.strt.get(key); + + return new lobject.TValue(CT.LUA_TLNGSTR, stringArray); } } diff --git a/src/ltable.js b/src/ltable.js index 36928d5..025efe0 100644 --- a/src/ltable.js +++ b/src/ltable.js @@ -64,7 +64,7 @@ Table.prototype.luaH_next = function(L, keyI) { if (tnidx === 'number' && nidx % 1 === 0) L.stack[keyI] = new TValue(CT.LUA_TNUMINT, indexes[i + 1]); else if (tnidx === 'string') - L.stack[keyI] = L.l_G.strt.get(indexes[i + 1]); + L.stack[keyI] = new TValue(CT.LUA_TLNGSTR, indexes[i + 1].split('|').map(e => Number.parseInt(e)).slice(0, -1)); else L.stack[keyI] = indexes[i + 1]; -- cgit v1.2.3-70-g09d2