Skip to content

Commit

Permalink
Improve performance of permutation parser.
Browse files Browse the repository at this point in the history
  • Loading branch information
renggli committed Jan 5, 2025
1 parent 75d5893 commit 7319064
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/src/parser/action/permute.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ class PermuteParser<R> extends DelegateParser<List<R>, List<R>> {
final result = delegate.parseOn(context);
if (result is Failure) return result;
final value = result.value;
final values = indexes
.map((index) => value[index < 0 ? value.length + index : index])
.toList(growable: false);
final values = List.generate(indexes.length, (i) {
final index = indexes[i];
return value[index < 0 ? value.length + index : index];
}, growable: false);
return result.success(values);
}

Expand Down

0 comments on commit 7319064

Please sign in to comment.