Skip to content

Commit 71cc20a

Browse files
LiviaMedeirosRafaelGSS
authored andcommitted
test: avoid apply() calls with large amount of elements
PR-URL: #55501 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
1 parent 1b82013 commit 71cc20a

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

‎test/parallel/test-buffer-includes.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,7 @@ assert(!asciiString.includes('\x2061'));
213213
assert(asciiString.includes('leb',0));
214214

215215
// Search in string containing many non-ASCII chars.
216-
constallCodePoints=[];
217-
for(leti=0;i<65534;i++)allCodePoints[i]=i;
218-
constallCharsString=String.fromCharCode.apply(String,allCodePoints)+
219-
String.fromCharCode(65534,65535);
216+
constallCharsString=Array.from({length: 65536},(_,i)=>String.fromCharCode(i)).join('');
220217
constallCharsBufferUtf8=Buffer.from(allCharsString);
221218
constallCharsBufferUcs2=Buffer.from(allCharsString,'ucs2');
222219

‎test/parallel/test-buffer-indexof.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,7 @@ assert.strictEqual(-1, asciiString.indexOf('\x2061'));
285285
assert.strictEqual(asciiString.indexOf('leb',0),3);
286286

287287
// Search in string containing many non-ASCII chars.
288-
constallCodePoints=[];
289-
for(leti=0;i<65534;i++)allCodePoints[i]=i;
290-
constallCharsString=String.fromCharCode.apply(String,allCodePoints)+
291-
String.fromCharCode(65534,65535);
288+
constallCharsString=Array.from({length: 65536},(_,i)=>String.fromCharCode(i)).join('');
292289
constallCharsBufferUtf8=Buffer.from(allCharsString);
293290
constallCharsBufferUcs2=Buffer.from(allCharsString,'ucs2');
294291

0 commit comments

Comments
(0)