Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(core): improve applyVariants method speed #1790

Merged
merged 2 commits into from Oct 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/core/src/generator/index.ts
Expand Up @@ -336,10 +336,9 @@ export class UnoGenerator {
}

private applyVariants(parsed: ParsedUtil, variantHandlers = parsed[4], raw = parsed[1]): UtilObject {
const handler = [...variantHandlers]
const handler = variantHandlers.slice()
.sort((a, b) => (a.order || 0) - (b.order || 0))
.reverse()
.reduce(
.reduceRight(
(previous, v) =>
(input: VariantHandlerContext) => {
const entries = v.body?.(input.entries) || input.entries
Expand Down