Skip to content

Commit

Permalink
performance: use assignment instead of object spread for better searc…
Browse files Browse the repository at this point in the history
…h performance (#2216)

* fix: reduce object assign

* fix: reduce object assign

* fix: revert empty line
  • Loading branch information
Jinbao1001 authored Oct 16, 2024
1 parent 0c33c6f commit e060c8e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/templates/meta/exports.ts.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,8 @@ export async function getFullDemos() {
// expand context for omit ext
expandDemoContext(demo.context);
});

return {
...total,
...demos,
};
Object.assign(total, demos);
return total;
}, {}),
);
}
Expand Down Expand Up @@ -184,10 +181,10 @@ export async function getFullRoutesMeta(): Promise<Record<string, IRouteMeta>> {
})),
).then((ret) =>
ret.reduce(
(total, { id, meta }) => ({
...total,
[id]: meta,
}),
(total, { id, meta }) => {
total[id] = meta;
return total;
},
{},
),
);
Expand Down

0 comments on commit e060c8e

Please sign in to comment.