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 725be0e

Browse filesBrowse files
anonrigdanielleadams
authored andcommitted
buffer: initialize TextDecoder once on blob.text()
PR-URL: #44787 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 281fd7a commit 725be0e
Copy full SHA for 725be0e

File tree

Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/blob.js‎

Copy file name to clipboardExpand all lines: lib/internal/blob.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ let ReadableStream;
7878
let URL;
7979

8080
const enc = new TextEncoder();
81+
let dec;
8182

8283
// Yes, lazy loading is annoying but because of circular
8384
// references between the url, internal/blob, and buffer
@@ -311,7 +312,8 @@ class Blob {
311312
if (!isBlob(this))
312313
throw new ERR_INVALID_THIS('Blob');
313314

314-
const dec = new TextDecoder();
315+
dec ??= new TextDecoder();
316+
315317
return dec.decode(await this.arrayBuffer());
316318
}
317319

0 commit comments

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