Skip to content

Commit 1e080fa

Browse files
committed
Skip the sort in joinErrors if the caller deems it unnecessary.
1 parent 6dbec99 commit 1e080fa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ometa/runtime.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,13 @@ def eof():
118118
return [("message", "end of input")]
119119

120120

121-
def joinErrors(errors):
121+
def joinErrors(errors, presorted=False):
122122
"""
123123
Return the error from the branch that matched the most of the input.
124124
"""
125-
errors.sort(reverse=True, key=operator.itemgetter(0))
125+
if not presorted:
126+
errors.sort(reverse=True, key=operator.itemgetter(0))
127+
126128
results = set()
127129
pos = errors[0].position
128130
trail = None
@@ -384,7 +386,7 @@ def considerError(self, error, typ=None):
384386
if error[0] > self.currentError[0]:
385387
self.currentError = error
386388
elif error[0] == self.currentError[0]:
387-
self.currentError = joinErrors([error, self.currentError])
389+
self.currentError = joinErrors([error, self.currentError], presorted=True)
388390

389391

390392
def _trace(self, src, span, inputPos):

0 commit comments

Comments
 (0)