Skip to content

Commit

Permalink
remove some unneeded code in Peek/Not (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnynek committed Mar 29, 2022
1 parent bfa5224 commit f3f988c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions core/shared/src/main/scala/cats/parse/Parser.scala
Expand Up @@ -1624,12 +1624,12 @@ object Parser {
* strings, for instance.
*/
def until0(p: Parser0[Any]): Parser0[String] =
(not(p).with1 ~ anyChar).rep0.string
repUntil0(anyChar, p).string

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

/** parse zero or more times until Parser `end` succeeds.
*/
Expand Down Expand Up @@ -3270,12 +3270,10 @@ object Parser {
* else fail
*/
case class Not(under: Parser0[Unit]) extends Parser0[Unit] {
// under is the result of a void, so we don't need to void here
override def parseMut(state: State): Unit = {
val offset = state.offset
val cap = state.capture
state.capture = false
under.parseMut(state)
state.capture = cap
if (state.error ne null) {
// under failed, so we succeed
state.error = null
Expand Down Expand Up @@ -3304,12 +3302,10 @@ object Parser {
* not advance
*/
case class Peek(under: Parser0[Unit]) extends Parser0[Unit] {
// note: under is already voided, so we don't need to adjust capture
override def parseMut(state: State): Unit = {
val offset = state.offset
val cap = state.capture
state.capture = false
under.parseMut(state)
state.capture = cap
if (state.error eq null) {
// under passed, so we succeed
state.offset = offset
Expand Down

0 comments on commit f3f988c

Please sign in to comment.