Skip to content

Avoid creating unnecessary strings in adjustExtension #9598

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
merged 2 commits into from
Aug 20, 2020

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Aug 19, 2020

No description provided.

# Conflicts:
#	compiler/src/dotty/tools/dotc/typer/Typer.scala
@odersky
Copy link
Contributor Author

odersky commented Aug 19, 2020

test performance please

@dottybot
Copy link
Member

performance test scheduled: 12 job(s) in queue, 1 running.

@dottybot
Copy link
Member

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/9598/ to see the changes.

Benchmarks is based on merging with master (6e6f67b)

@odersky
Copy link
Contributor Author

odersky commented Aug 20, 2020

That one gives a clear win for dotc. For stdlib we see the same pattern as in the optimize-megaphase commit: go back up to the norm after a very low number for optimize-current. But it seems optimize-current is part of these two as well since it is in master. Which leaves as only explanation for me that we got an outlier for stdlib when we tested optimize-current.

Copy link
Contributor

@liufengyun liufengyun 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

@@ -216,7 +216,10 @@ class Typer extends Namer
val termName = name.toTermName

def adjustExtension(name: Name) =
if required.is(ExtensionMethod) then name.toExtensionName else name
if required.is(ExtensionMethod) && termName.endsWith(name.lastPart)
// pre-check to avoid forming a new string; form extension only if it has a chance of matching `termName`
Copy link
Contributor

Choose a reason for hiding this comment

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

Will termName.endsWith(name.lastPart) be always true, given that termName = name.toTermName?

@odersky odersky merged commit 188b99c into scala:master Aug 20, 2020
@odersky odersky deleted the optimize-adjustExtension branch August 20, 2020 14:35
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