Skip to content

Commit d811a1d

Browse files
committed
[INTERNAL] Use Object.create(null) for dynamic maps
1 parent 0d16ccc commit d811a1d

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

lib/lbt/resources/LibraryFileAnalyzer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function createRawInfo(rawModule) {
4949
}
5050

5151
export function getDependencyInfos( name, content ) {
52-
const infos = {};
52+
const infos = Object.create(null);
5353
parser.parseString(content, (err, result) => {
5454
if ( result &&
5555
result.library &&

lib/lbt/resources/ModuleInfo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ModuleInfo {
3939
constructor(name) {
4040
this._name = name;
4141
this.subModules = [];
42-
this._dependencies = {};
42+
this._dependencies = Object.create(null);
4343
this.dynamicDependencies = false;
4444

4545
/**

lib/processors/manifestCreator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ async function createManifest(
349349
}
350350

351351
function collectThemes() {
352-
const themes = {};
352+
const themes = Object.create(null);
353353

354354
// find theme resources and determine theme names from their paths
355355
libBundle.getResources(/(?:[^/]+\/)*themes\//).forEach((res) => {

lib/processors/nonAsciiEscaper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import escapeUnicode from "escape-unicode";
1414
const CHAR_CODE_OF_LAST_ASCII_CHARACTER = 127;
1515

1616
// use memoization for escapeUnicode function for performance
17-
const memoizeEscapeUnicodeMap = {};
17+
const memoizeEscapeUnicodeMap = Object.create(null);
1818
const memoizeEscapeUnicode = function(sChar) {
1919
if (memoizeEscapeUnicodeMap[sChar]) {
2020
return memoizeEscapeUnicodeMap[sChar];

lib/processors/versionInfoGenerator.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ function getTimestamp() {
6060
const processManifest = async (manifestResource) => {
6161
const manifestContent = await manifestResource.getString();
6262
const manifestObject = JSON.parse(manifestContent);
63-
const manifestInfo = {};
63+
const manifestInfo = Object.create(null);
6464

6565
// sap.ui5/dependencies is used for the "manifestHints/libs"
6666
if (manifestObject["sap.ui5"]) {
6767
const manifestDependencies = manifestObject["sap.ui5"]["dependencies"];
6868
if (manifestDependencies && manifestDependencies.libs) {
69-
const libs = {};
69+
const libs = Object.create(null);
7070
for (const [libKey, libValue] of Object.entries(manifestDependencies.libs)) {
71-
libs[libKey] = {};
71+
libs[libKey] = Object.create(null);
7272
if (libValue.lazy) {
7373
libs[libKey].lazy = true;
7474
}
@@ -230,7 +230,7 @@ class DependencyInfo {
230230
* @returns {object} the object with sorted keys
231231
*/
232232
const sortObjectKeys = (obj) => {
233-
const sortedObject = {};
233+
const sortedObject = Object.create(null);
234234
const keys = Object.keys(obj);
235235
keys.sort();
236236
keys.forEach((key) => {
@@ -433,7 +433,7 @@ export default async function({options}) {
433433
let components;
434434
artifactInfos.forEach((artifactInfo) => {
435435
artifactInfo.embeds.forEach((embeddedArtifactInfo) => {
436-
const componentObject = {};
436+
const componentObject = Object.create(null);
437437
const bundledComponents = artifactInfo.bundledComponents;
438438
const componentName = embeddedArtifactInfo.componentName;
439439
if (!bundledComponents.has(componentName)) {
@@ -446,7 +446,7 @@ export default async function({options}) {
446446
componentObject.manifestHints = manifestHints;
447447
}
448448

449-
components = components || {};
449+
components = components || Object.create(null);
450450
components[componentName] = componentObject;
451451
});
452452
});

lib/tasks/bundlers/utils/createModuleNameMapping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {getNonDebugName} from "../../../lbt/utils/ModuleName.js";
1515
* @returns {object} Module name mapping
1616
*/
1717
export default function({resources, taskUtil}) {
18-
const moduleNameMapping = {};
18+
const moduleNameMapping = Object.create(null);
1919
for (let i = resources.length - 1; i >= 0; i--) {
2020
const resource = resources[i];
2121
if (taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant)) {

lib/tasks/generateCachebusterInfo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function({workspace, options}) {
5757
const basePath = `/resources/${namespace}/`;
5858
return workspace.byGlob(`/resources/${namespace}/**/*`)
5959
.then(async (resources) => {
60-
const cachebusterInfo = {};
60+
const cachebusterInfo = Object.create(null);
6161
const signer = getSigner(signatureType);
6262

6363
await Promise.all(resources.map(async (resource) => {

0 commit comments

Comments
 (0)