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 useless match in liftTokenizer #2899

Merged
merged 2 commits into from
Oct 2, 2023
Merged

Remove useless match in liftTokenizer #2899

merged 2 commits into from
Oct 2, 2023

Conversation

guizmaii
Copy link
Member

Found this thanks to research done in #2886

Comment on lines +22 to +25
implicit final val jsonAstEncoder: Encoder[JsonValue[Json]] = astEncoder(_.value.toString(), "json")
implicit final val jsonAstDecoder: Decoder[JsonValue[Json]] = astDecoder(JsonValue(_))
implicit final val jsonbAstEncoder: Encoder[JsonbValue[Json]] = astEncoder(_.value.toString(), "jsonb")
implicit final val jsonbAstDecoder: Decoder[JsonbValue[Json]] = astDecoder(JsonbValue(_))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to compute them more than once

Comment on lines +22 to +25
implicit final val jsonAstEncoder: Encoder[JsonValue[Json]] = astEncoder(_.value.toString(), "json")
implicit final val jsonAstDecoder: Decoder[JsonValue[Json]] = astDecoder(JsonValue(_))
implicit final val jsonbAstEncoder: Encoder[JsonbValue[Json]] = astEncoder(_.value.toString(), "jsonb")
implicit final val jsonbAstDecoder: Decoder[JsonbValue[Json]] = astDecoder(JsonbValue(_))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to compute them more than once

Comment on lines +95 to +100
implicit val tokenTokenizer: Tokenizer[Token] = Tokenizer[Token](identity)
implicit val statementTokenizer: Tokenizer[Statement] =
Tokenizer[Statement](identity)
implicit def stringTokenTokenizer: Tokenizer[StringToken] =
implicit val stringTokenTokenizer: Tokenizer[StringToken] =
Tokenizer[StringToken](identity)
implicit def liftingTokenTokenizer: Tokenizer[ScalarLiftToken] =
implicit val liftingTokenTokenizer: Tokenizer[ScalarLiftToken] =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to compute them more than once

Comment on lines -54 to -58
case tag: ScalarTag => ScalarTagToken(tag)
case tag: QuotationTag => QuotationTagToken(tag)
case lift: ScalarLift => ScalarLiftToken(lift)
// TODO Longer Explanation
case lift: Tag => fail("Cannot tokenizer a non-scalar tagging.")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT, a Lift can't be a ScalarTag, nor a QuotationTag nor a Tag

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I think there was a point at which Tag was a sub-type of Lift but I changed that a while ago.

new Tokenizer[T] {
private val stable = fallback(this)
override def token(v: T) = pf.applyOrElse(v, stable.token)
private lazy val stable: Tokenizer[T] = fallback(this)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was weird to me. Why would we need to compute the fallback value before to know if we'll ever need it one day? 🤔

@guizmaii guizmaii merged commit b3e909f into master Oct 2, 2023
13 checks passed
@guizmaii guizmaii deleted the clean_2 branch October 2, 2023 05:26
jilen pushed a commit that referenced this pull request Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants