Skip to content

Avoid retraversing parts of the tree that do not contain Quote trees #17407

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

Merged

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented May 4, 2023

Also, remove an illegal use of WildcardType.

@nicolasstucki nicolasstucki force-pushed the pickle-quotes-small-optimization branch from 1cf6b91 to c27f870 Compare May 12, 2023 08:17
@nicolasstucki nicolasstucki requested review from smarter and removed request for natsukagami May 12, 2023 08:17
@nicolasstucki nicolasstucki assigned smarter and unassigned natsukagami May 12, 2023
val contents1 = contents ::: quote.tags
val pickled = PickleQuotes.pickle(quote2, quotes, contents1)
transform(pickled) // pickle quotes that are in the contents
val contents1 = contents.map(transform(_)) ::: quote.tags
Copy link
Member

Choose a reason for hiding this comment

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

By the way, why are the tags after the content? Aren't they referenced in the body?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tags will not contain quotes, they are all TermRefs. Therfore we know that this transformation will have no effect.

Copy link
Member

Choose a reason for hiding this comment

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

right, I mean, why isn't it quote.tags ::: contents.map(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The order was irrelevant as we split them in PickleQuotes.pickle. This also deserves some optimization. I will add a commit for that.

Copy link
Contributor Author

@nicolasstucki nicolasstucki May 12, 2023

Choose a reason for hiding this comment

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

It was added at the end because of a zipWithIndex that we needed for the contents but not the tags. There was a TODO to cleanup that mess.

if typeSplices.isEmpty then Literal(Constant(null)) // keep pickled quote without contents as small as possible
else SeqLiteral(typeSplices.map(_._1), TypeTree(defn.QuotedTypeClass.typeRef.appliedTo(WildcardType)))
if quote.tags.isEmpty then Literal(Constant(null)) // keep pickled quote without holeContents as small as possible
else SeqLiteral(quote.tags, TypeTree(defn.QuotedTypeClass.typeRef.appliedTo(WildcardType)))
Copy link
Member

Choose a reason for hiding this comment

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

Note that WildcardType isn't supposed to appear in types of trees, only in prototypes for inference, the argment of Foo[?] should be represented with a TypeBounds instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced it with TypeBounds.emptyPolyKind.

@nicolasstucki nicolasstucki requested a review from smarter May 15, 2023 13:14
Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

@smarter smarter assigned nicolasstucki and unassigned smarter May 15, 2023
@nicolasstucki nicolasstucki enabled auto-merge May 16, 2023 08:03
@nicolasstucki nicolasstucki merged commit 9923e29 into scala:main May 16, 2023
@nicolasstucki nicolasstucki deleted the pickle-quotes-small-optimization branch May 16, 2023 11:50
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.

3 participants