Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove some unneeded code in Peek/Not #401

Merged
merged 2 commits into from
Mar 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions core/shared/src/main/scala/cats/parse/Parser.scala
Original file line number Diff line number Diff line change
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