Skip to content

Commit

Permalink
src/lstrlib.js: remove String.repeat usage in the string library
Browse files Browse the repository at this point in the history
  • Loading branch information
daurnimator committed Mar 14, 2019
1 parent c3bc19f commit 8cbc96e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lstrlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ const addquoted = function(b, s, len) {
luaL_addchar(b, 92 /* '\\'.charCodeAt(0) */);
luaL_addchar(b, s[i]);
} else if (iscntrl(s[i])) {
let buff = ''+s[i];
let buff = "" + s[i]; /* stringify */
if (isdigit(s[i+1]))
buff = '0'.repeat(3-buff.length) + buff; /* pad to 3 '0's */
buff = ("000" + buff).slice(-3); /* pad to 3 digits with leading '0's */
luaL_addstring(b, to_luastring("\\" + buff));
} else
luaL_addchar(b, s[i]);
Expand Down

0 comments on commit 8cbc96e

Please sign in to comment.