Skip to content

Commit

Permalink
Revert the SingleCharacterParser single read
Browse files Browse the repository at this point in the history
  • Loading branch information
renggli committed Jan 2, 2025
1 parent 677a3e6 commit 6a1657f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/src/parser/predicate/single_character.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ class SingleCharacterParser extends CharacterParser {
Result<String> parseOn(Context context) {
final buffer = context.buffer;
final position = context.position;
if (position < buffer.length) {
final codeUnit = buffer.codeUnitAt(position);
if (predicate.test(codeUnit)) {
return context.success(String.fromCharCode(codeUnit), position + 1);
}
}
return context.failure(message);
return position < buffer.length &&
predicate.test(buffer.codeUnitAt(position))
? context.success(buffer[position], position + 1)
: context.failure(message);
}

@override
Expand Down

0 comments on commit 6a1657f

Please sign in to comment.