Rollup merge of #107930 - GuillaumeGomez:js-func-improvement, r=notriddle
Improve JS function itemTypeFromName code a bit Very small code improvement replacing a `for` loop with `findIndex` method. r? ````@notriddle````
This commit is contained in:
commit
76c47fb904
@ -142,13 +142,11 @@ function initSearch(rawSearchIndex) {
|
||||
}
|
||||
|
||||
function itemTypeFromName(typename) {
|
||||
for (let i = 0, len = itemTypes.length; i < len; ++i) {
|
||||
if (itemTypes[i] === typename) {
|
||||
return i;
|
||||
}
|
||||
const index = itemTypes.findIndex(i => i === typename);
|
||||
if (index < 0) {
|
||||
throw new Error("Unknown type filter `" + typename + "`");
|
||||
}
|
||||
|
||||
throw new Error("Unknown type filter `" + typename + "`");
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user