Skip to content

Commit f3f988c

Browse files
authored
remove some unneeded code in Peek/Not (#401)
1 parent bfa5224 commit f3f988c

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

core/shared/src/main/scala/cats/parse/Parser.scala

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,12 +1624,12 @@ object Parser {
16241624
* strings, for instance.
16251625
*/
16261626
def until0(p: Parser0[Any]): Parser0[String] =
1627-
(not(p).with1 ~ anyChar).rep0.string
1627+
repUntil0(anyChar, p).string
16281628

16291629
/** parse one or more characters as long as they don't match p
16301630
*/
16311631
def until(p: Parser0[Any]): Parser[String] =
1632-
(not(p).with1 ~ anyChar).rep.string
1632+
repUntil(anyChar, p).string
16331633

16341634
/** parse zero or more times until Parser `end` succeeds.
16351635
*/
@@ -3270,12 +3270,10 @@ object Parser {
32703270
* else fail
32713271
*/
32723272
case class Not(under: Parser0[Unit]) extends Parser0[Unit] {
3273+
// under is the result of a void, so we don't need to void here
32733274
override def parseMut(state: State): Unit = {
32743275
val offset = state.offset
3275-
val cap = state.capture
3276-
state.capture = false
32773276
under.parseMut(state)
3278-
state.capture = cap
32793277
if (state.error ne null) {
32803278
// under failed, so we succeed
32813279
state.error = null
@@ -3304,12 +3302,10 @@ object Parser {
33043302
* not advance
33053303
*/
33063304
case class Peek(under: Parser0[Unit]) extends Parser0[Unit] {
3305+
// note: under is already voided, so we don't need to adjust capture
33073306
override def parseMut(state: State): Unit = {
33083307
val offset = state.offset
3309-
val cap = state.capture
3310-
state.capture = false
33113308
under.parseMut(state)
3312-
state.capture = cap
33133309
if (state.error eq null) {
33143310
// under passed, so we succeed
33153311
state.offset = offset

0 commit comments

Comments
 (0)