Skip to content

Commit

Permalink
tools: dedupe property access in doc/type-parser
Browse files Browse the repository at this point in the history
There is no need to get this property twice in this rather hot spot:
if there is no such key, the `typeUrl` will be `undefined`,
which suffices for the boolean check in the next line.

For consistency, `undefined` can also be made the default value.

PR-URL: #20387
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
vsemozhetbyt authored and MylesBorins committed May 4, 2018
1 parent fcc5492 commit b0c0352
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/doc/type-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function toLink(typeInput) {
typeTexts.forEach((typeText) => {
typeText = typeText.trim();
if (typeText) {
let typeUrl = null;
let typeUrl;

// To support type[], type[][] etc., we store the full string
// and use the bracket-less version to lookup the type URL.
Expand All @@ -143,7 +143,7 @@ function toLink(typeInput) {
typeUrl = `${jsDataStructuresUrl}#${primitive}_type`;
} else if (jsGlobalTypes.includes(typeText)) {
typeUrl = `${jsGlobalObjectsUrl}${typeText}`;
} else if (customTypesMap[typeText]) {
} else {
typeUrl = customTypesMap[typeText];
}

Expand Down

0 comments on commit b0c0352

Please sign in to comment.