From 6ffe07fc5d16ee9acdcd6651d433ce13b193cd15 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 7 Jan 2018 02:07:17 +1100 Subject: TypedArray.toString() doesn't return a unique string in some browsers e.g. IE11 Instead iterate over string contents and manually build hash. I have *not* tested this for performance. An alternative option is to use Array.prototype.join.call --- src/defs.js | 9 ++++++++- src/lstring.js | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/defs.js b/src/defs.js index b96dcf5..c0b3bda 100644 --- a/src/defs.js +++ b/src/defs.js @@ -159,7 +159,14 @@ const is_luastring = function(s) { /* test two lua strings for equality */ const luastring_eq = function(a, b) { - return a === b || (a.length === b.length && a.toString() === b.toString()); + if (a !== b) { + let len = a.length; + if (len !== b.length) return false; + /* XXX: Should this be a constant time algorithm? */ + for (let i=0; i