Skip to content

Commit

Permalink
Performance: avoid Object.values call for Array instances
Browse files Browse the repository at this point in the history
  • Loading branch information
jayaddison committed Nov 6, 2024
1 parent 6b4b675 commit ab841c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sphinx/themes/basic/static/searchtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,12 @@ const Search = {
while (stack.length) {
const value = stack.pop();
if (!(value instanceof Object)) continue;
stack.push(...Object.values(value));
if (!Array.isArray(value)) Object.setPrototypeOf(value, null);
if (Array.isArray(value)) {
stack.push(...value);
} else {
stack.push(...Object.values(value));
Object.setPrototypeOf(value, null);
}
Object.freeze(value);
}
Search._index = index;
Expand Down

0 comments on commit ab841c6

Please sign in to comment.