Move backtracking for implements to specific spaces case that it's actually needed for, to avoid excess parsing work in extreme cases

This commit is contained in:
Joshua Warner 2025-01-03 19:29:19 -08:00
parent 6edfc0aa90
commit 090473434d
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
4 changed files with 6 additions and 24 deletions

View file

@ -186,7 +186,7 @@ where
E: 'a + SpaceProblem,
{
parser::map(
and(space0_e(indent_problem), parser),
and(backtrackable(space0_e(indent_problem)), parser),
|(space_list, item): (&'a [CommentOrNewline<'a>], S)| SpacesBefore {
before: space_list,
item,

View file

@ -1163,10 +1163,7 @@ fn opaque_signature<'a>(
and(
specialize_err(EExpr::Type, type_annotation::located_opaque_signature(true)),
optional(map_with_arena(
backtrackable(specialize_err(
EExpr::Type,
type_annotation::implements_abilities(),
)),
specialize_err(EExpr::Type, type_annotation::implements_abilities()),
|arena, item| &*arena.alloc(item),
)),
)