Skip to content

Commit

Permalink
[BUGFIX] Use Set() instead of custom array unique implementation
Browse files Browse the repository at this point in the history
JavaScript has a native Set() object that ensures uniqueness of values
by design and is therefore faster than any custom uniqueness
implementation.

The Install Tool had an obvious implementation that is superseded by
`Set()`, being several milliseconds faster, depending on the client's
CPU.

Resolves: #99987
Releases: main, 11.5
Change-Id: I6b566b97c70b241070b78b841350a6b21b64a5a6
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77901
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Oliver Bartsch <bo@cedev.de>
  • Loading branch information
andreaskienast authored and o-ba committed Feb 20, 2023
1 parent 74d2ab6 commit 67bdbe1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class ExtensionScanner extends AbstractInteractableModule {
install: {
action: 'extensionScannerMarkFullyScannedRestFiles',
token: this.getModuleContent().data('extension-scanner-mark-fully-scanned-rest-files-token'),
hashes: this.uniqueArray(this.listOfAffectedRestFileHashes),
hashes: Array.from(new Set(this.listOfAffectedRestFileHashes)),
},
}).then(
async (response: AjaxResponse): Promise<any> => {
Expand All @@ -179,15 +179,6 @@ class ExtensionScanner extends AbstractInteractableModule {
}
}

/**
* Helper method removing duplicate entries from an array
*/
private uniqueArray(anArray: Array<any>): Array<any> {
return anArray.filter((value: any, index: number, self: any): boolean => {
return self.indexOf(value) === index;
});
}

/**
* Handle a single extension scan
*/
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 67bdbe1

Please sign in to comment.