changeset 48:26fd19b2573d draft

combinators: Microoptimization in Repeat
author Lewin Bormann <lbo@spheniscida.de>
date Thu, 23 May 2019 22:28:32 +0200
parents c7658385dc5f
children 9f7c57e5ef26
files pcombinators/combinators.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pcombinators/combinators.py	Thu May 23 22:24:29 2019 +0200
+++ b/pcombinators/combinators.py	Thu May 23 22:28:32 2019 +0200
@@ -148,7 +148,7 @@
 
     def parse(self, st):
         results = []
-        hold = st.hold()
+        hold = st.hold() if self._strict else None
         i = 0
 
         while i < self._times or self._times < 0:
@@ -157,7 +157,7 @@
                 if self._strict:
                     st.reset(hold)
                     return None, st
-                st.release(hold)
+                assert hold is None
                 if len(results) == 0:
                     return SKIP_MARKER, st2
                 return results, st2