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

Missed optimization opportunities #2

Closed
lukaslueg opened this Issue Aug 12, 2018 · 1 comment

Comments

1 participant
@lukaslueg
Copy link
Owner

lukaslueg commented Aug 12, 2018

The foldcommontails-walker currently misses some opportunities as demonstrated here (the optional mut should be folded) and here (the pub should be folded).

The problem most likely is that the optimizer might produce a Choice of just one element, when it effectivly becomes a Sequence. Since it can not "look into" a Choice when evaluating common tails, it misses out.

The fix is probably to implement a simplifying pass that

  • Turns Choice of exactly one element into Sequence
  • Turns Sequence of exactly one element into that element
  • Removes the needless Sequence in a Repeat
  • and such.

There are situations where we do this manually now; get rid of them.

The result of the folding pass should be simplified before re-evaluating the current Choice for more opportunities. The overall result should also be simplified.

lukaslueg added a commit that referenced this issue Aug 26, 2018

Make folding-pass less smart-alec, add normalization-/ungroup-pass
The folding-pass would get stuck by unboxing elements prematurely.
Make it less aggressive, leaving some cruft behind, and introduce a more
powerful normalization-pass. Fixes issue #2.
Add an ungrouper-pass, which unpacks Groups left by transforming the
parser-tree if so wanted.
@lukaslueg

This comment has been minimized.

Copy link
Owner

lukaslueg commented Aug 26, 2018

Should be good for now

@lukaslueg lukaslueg closed this Aug 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment