Skip to content

Commit 84df719

Browse files
committed
Small optimization
1 parent d7e56c6 commit 84df719

File tree

1 file changed

+8
-0
lines changed
  • turbopack/crates/turbopack-core/src/resolve

1 file changed

+8
-0
lines changed

turbopack/crates/turbopack-core/src/resolve/pattern.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,14 @@ impl Pattern {
378378

379379
/// Appends something to end the pattern.
380380
pub fn push(&mut self, pat: Pattern) {
381+
if let Pattern::Constant(this) = &*self
382+
&& this.is_empty()
383+
{
384+
// Short-circuit to replace empty constants with the appended pattern
385+
*self = pat;
386+
return;
387+
}
388+
381389
match (self, pat) {
382390
(Pattern::Concatenation(list), Pattern::Concatenation(more)) => {
383391
concatenation_extend_or_merge_items(list, more.into_iter());

0 commit comments

Comments
 (0)