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 b966ef9

Browse filesBrowse files
legendecasruyadorno
authored andcommitted
lib: remove unnecessary ObjectGetValueSafe
PR-URL: #46335 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent bf62da5 commit b966ef9
Copy full SHA for b966ef9

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

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

‎lib/internal/source_map/source_map_cache.js‎

Copy file name to clipboardExpand all lines: lib/internal/source_map/source_map_cache.js
+8-18Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,12 @@ const {
44
ArrayPrototypeMap,
55
JSONParse,
66
ObjectKeys,
7-
ObjectGetOwnPropertyDescriptor,
8-
ObjectPrototypeHasOwnProperty,
97
RegExpPrototypeExec,
108
RegExpPrototypeSymbolSplit,
119
SafeMap,
1210
StringPrototypeSplit,
1311
} = primordials;
1412

15-
function ObjectGetValueSafe(obj, key) {
16-
const desc = ObjectGetOwnPropertyDescriptor(obj, key);
17-
if (desc === undefined) {
18-
return undefined;
19-
}
20-
return ObjectPrototypeHasOwnProperty(desc, 'value') ? desc.value : undefined;
21-
}
22-
2313
// See https://sourcemaps.info/spec.html for SourceMap V3 specification.
2414
const { Buffer } = require('buffer');
2515
let debug = require('internal/util/debuglog').debuglog('source_map', (fn) => {
@@ -301,11 +291,11 @@ function sourceMapCacheToObject() {
301291

302292
function appendCJSCache(obj) {
303293
for (const value of getCjsSourceMapCache()) {
304-
obj[ObjectGetValueSafe(value, 'filename')] = {
294+
obj[value.filename] = {
305295
__proto__: null,
306-
lineLengths: ObjectGetValueSafe(value, 'lineLengths'),
307-
data: ObjectGetValueSafe(value, 'data'),
308-
url: ObjectGetValueSafe(value, 'url')
296+
lineLengths: value.lineLengths,
297+
data: value.data,
298+
url: value.url,
309299
};
310300
}
311301
}
@@ -320,8 +310,8 @@ function findSourceMap(sourceURL) {
320310
let entry = esmSourceMapCache.get(sourceURL) ?? generatedSourceMapCache.get(sourceURL);
321311
if (entry === undefined) {
322312
for (const value of getCjsSourceMapCache()) {
323-
const filename = ObjectGetValueSafe(value, 'filename');
324-
const cachedSourceURL = ObjectGetValueSafe(value, 'sourceURL');
313+
const filename = value.filename;
314+
const cachedSourceURL = value.sourceURL;
325315
if (sourceURL === filename || sourceURL === cachedSourceURL) {
326316
entry = value;
327317
}
@@ -330,9 +320,9 @@ function findSourceMap(sourceURL) {
330320
if (entry === undefined) {
331321
return undefined;
332322
}
333-
let sourceMap = ObjectGetValueSafe(entry, 'sourceMap');
323+
let sourceMap = entry.sourceMap;
334324
if (sourceMap === undefined) {
335-
sourceMap = new SourceMap(ObjectGetValueSafe(entry, 'data'));
325+
sourceMap = new SourceMap(entry.data);
336326
entry.sourceMap = sourceMap;
337327
}
338328
return sourceMap;

0 commit comments

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