Skip to content

Use inline val for inlined final vals #13989

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 1 commit into from
Nov 24, 2021

Conversation

nicolasstucki
Copy link
Contributor

These vals are already inlined and do not generate a field, but they
still generate a getter that is never used. My marking these as inline
we can remove the getter and save a few bytes at runtime.

By making these fields inline we can also check that the RHS constant
folds to a value at compile time.

@nicolasstucki nicolasstucki self-assigned this Nov 22, 2021
@nicolasstucki nicolasstucki changed the title Use inline val for inlined final vals Use inline val for inlined final vals Nov 22, 2021
These `val`s are already inlined and do not generate a field, but they
still generate a getter that is never used. My marking these as `inline`
we can remove the getter and save a few bytes at runtime.

By making these fields `inline` we can also check that the RHS constant
folds to a value at compile time.
@nicolasstucki nicolasstucki force-pushed the use-inline-val-in-compiler branch from 9874d9a to eba5290 Compare November 22, 2021 09:38
@nicolasstucki nicolasstucki marked this pull request as ready for review November 22, 2021 14:29
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.

but they still generate a getter that is never used

Is that getter public? If so that sounds like a binary-breaking change so not something we could do in scala 3.

@nicolasstucki
Copy link
Contributor Author

Those are only in the compiler. Not in the library.

@smarter
Copy link
Member

smarter commented Nov 23, 2021

test performance please

@nicolasstucki
Copy link
Contributor Author

Test performance please

@nicolasstucki
Copy link
Contributor Author

@anatoliykmetyuk the benchmarking machine is not responding.

@anatoliykmetyuk
Copy link
Contributor

test performance please

@dottybot
Copy link
Member

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

@dottybot
Copy link
Member

Performance test finished successfully:

Visit https://dotty-bench.epfl.ch/13989/ to see the changes.

Benchmarks is based on merging with master (ca483f8)

@smarter smarter merged commit b735803 into scala:master Nov 24, 2021
@smarter smarter deleted the use-inline-val-in-compiler branch November 24, 2021 14:45
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.

4 participants