mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-15 20:45:45 +03:00
Improve JS function itemTypeFromName code a bit
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user