polux / parsers

Parser Combinators for Dart
Other
23 stars 10 forks source link

Make expectations computation lazy. #18

Closed dikmax closed 8 years ago

dikmax commented 9 years ago

Idea behind optimization that errorMessage we use only when needed but computing expectations all the time. And operations on sets are very expensive. So I delay this operation until it really needed.

My test started working twice fast.

polux commented 8 years ago

Nice! I think you could make it a bit shorter by using a linked list (there is one in persistent, which this lib depends on). I can merge you PR now and do the change myself, or you can give it a shot, as you wish.

Either way, thanks!

dikmax commented 8 years ago

Actually I can't see how LinkedList could help here. So make it yourself. Thanks!

polux commented 8 years ago

I meant that EmptyExpectation | SingleExpectation | CombinedExpectation is isomorphic to LinkedList, more or less. I'll give it a try later but it's anyway already much better than how it was before.

polux commented 8 years ago

Published in version 0.14.5.

polux commented 8 years ago

Nevermind about my remark: what you want is not a list but a tree (or a list with lazy concatenation), which is exactly what you have.