Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 71cc20a

Browse filesBrowse files
LiviaMedeirosRafaelGSS
authored andcommitted
test: avoid apply() calls with large amount of elements
PR-URL: #55501 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
1 parent 1b82013 commit 71cc20a
Copy full SHA for 71cc20a

File tree

Expand file treeCollapse file tree

2 files changed

+2
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+2
-8
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-includes.js
+1-4Lines 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-
const allCodePoints = [];
217-
for (let i = 0; i < 65534; i++) allCodePoints[i] = i;
218-
const allCharsString = String.fromCharCode.apply(String, allCodePoints) +
219-
String.fromCharCode(65534, 65535);
216+
const allCharsString = Array.from({ length: 65536 }, (_, i) => String.fromCharCode(i)).join('');
220217
const allCharsBufferUtf8 = Buffer.from(allCharsString);
221218
const allCharsBufferUcs2 = Buffer.from(allCharsString, 'ucs2');
222219

Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-indexof.js
+1-4Lines 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-
const allCodePoints = [];
289-
for (let i = 0; i < 65534; i++) allCodePoints[i] = i;
290-
const allCharsString = String.fromCharCode.apply(String, allCodePoints) +
291-
String.fromCharCode(65534, 65535);
288+
const allCharsString = Array.from({ length: 65536 }, (_, i) => String.fromCharCode(i)).join('');
292289
const allCharsBufferUtf8 = Buffer.from(allCharsString);
293290
const allCharsBufferUcs2 = Buffer.from(allCharsString, 'ucs2');
294291

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.