Skip to content

Commit

Permalink
test: avoid apply() calls with large amount of elements
Browse files Browse the repository at this point in the history
PR-URL: #55501
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
  • Loading branch information
LiviaMedeiros authored Oct 26, 2024
1 parent f0e5b6a commit 5e27e59
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
5 changes: 1 addition & 4 deletions test/parallel/test-buffer-includes.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,7 @@ assert(!asciiString.includes('\x2061'));
assert(asciiString.includes('leb', 0));

// Search in string containing many non-ASCII chars.
const allCodePoints = [];
for (let i = 0; i < 65534; i++) allCodePoints[i] = i;
const allCharsString = String.fromCharCode.apply(String, allCodePoints) +
String.fromCharCode(65534, 65535);
const allCharsString = Array.from({ length: 65536 }, (_, i) => String.fromCharCode(i)).join('');
const allCharsBufferUtf8 = Buffer.from(allCharsString);
const allCharsBufferUcs2 = Buffer.from(allCharsString, 'ucs2');

Expand Down
5 changes: 1 addition & 4 deletions test/parallel/test-buffer-indexof.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,7 @@ assert.strictEqual(-1, asciiString.indexOf('\x2061'));
assert.strictEqual(asciiString.indexOf('leb', 0), 3);

// Search in string containing many non-ASCII chars.
const allCodePoints = [];
for (let i = 0; i < 65534; i++) allCodePoints[i] = i;
const allCharsString = String.fromCharCode.apply(String, allCodePoints) +
String.fromCharCode(65534, 65535);
const allCharsString = Array.from({ length: 65536 }, (_, i) => String.fromCharCode(i)).join('');
const allCharsBufferUtf8 = Buffer.from(allCharsString);
const allCharsBufferUcs2 = Buffer.from(allCharsString, 'ucs2');

Expand Down

0 comments on commit 5e27e59

Please sign in to comment.