Permalink
Browse files

optimize And pattern when either side is a wildcard

  • Loading branch information...
1 parent a16896e commit 5e79d9881ebd89cca041550b9ef6b0697caf32af @vito committed Jun 3, 2012
Showing with 21 additions and 13 deletions.
  1. +21 −13 kernel/patterns.ay
View
34 kernel/patterns.ay
@@ -104,23 +104,31 @@ Atomy Patterns open:
target(g, mod) := @a target(g, mod)
- matches(g, mod)? := do:
- mismatch = g new-label
- done = g new-label
+ matches(g, mod)? :=
+ condition:
+ @a wildcard? ->
+ @b matches(g, mod)?
- g dup
- @a matches(g, mod)?
- g gif(mismatch)
+ @b wildcard? ->
+ @a matches(g, mod)?
- @b matches(g, mod)?
- g dup
- g git(done)
+ otherwise:
+ mismatch = g new-label
+ done = g new-label
- mismatch set!
- g pop
- g push-false
+ g dup
+ @a matches(g, mod)?
+ g gif(mismatch)
- done set!
+ @b matches(g, mod)?
+ g dup
+ g git(done)
+
+ mismatch set!
+ g pop
+ g push-false
+
+ done set!
deconstruct(g, mod, locals = Hash new) := do:
g dup

0 comments on commit 5e79d98

Please sign in to comment.