Skip to content

Commit 1fd926a

Browse files
perf(core): skip redundant shortcut variant matching (#5233)
1 parent 04d6e13 commit 1fd926a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

packages-engine/core/src/generator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class UnoGeneratorInternal<Theme extends object = object> {
153153
context.variants = [...matched[3]]
154154

155155
// expand shortcuts
156-
const expanded = await this.expandShortcut(context.currentSelector, context)
156+
const expanded = await this.expandShortcut(context.currentSelector, context, 5, true)
157157
const utils = expanded
158158
? await this.stringifyShortcuts(context.variantMatch, context, expanded[0], expanded[1])
159159
// no shortcuts
@@ -793,6 +793,7 @@ class UnoGeneratorInternal<Theme extends object = object> {
793793
input: string,
794794
context: RuleContext<Theme>,
795795
depth = 5,
796+
skipVariantMatch = false,
796797
): Promise<[(string | ShortcutInlineValue)[], RuleMeta | undefined] | undefined> {
797798
if (depth === 0)
798799
return
@@ -844,7 +845,7 @@ class UnoGeneratorInternal<Theme extends object = object> {
844845
}
845846

846847
// expand nested shortcuts with variants
847-
if (!result) {
848+
if (!result && !skipVariantMatch) {
848849
const matched = isString(input) ? await this.matchVariants(input) : [input]
849850
for (const match of matched) {
850851
const [raw, inputWithoutVariant, handles] = match

0 commit comments

Comments
 (0)