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

Replace all simple nqp::if(42,foo,bar) with ternaries #3957

Merged
merged 2 commits into from Oct 26, 2020
Merged

Conversation

lizmat
Copy link
Contributor

@lizmat lizmat commented Oct 14, 2020

If memory serves me well, about 1.5 years ago, optimizations in
Rakudo made the construct:

42 ?? foo !! bar

equally fast as the nqp equivalent:

nqp::if(42,foo,bar)

This commit converts all of the simple nqp::if() structures in the
core.c setting to their ternary equivalents.

  • binary size of CORE.c.setting.moarvm file is unchanged (almost)
  • speed should be on par with the nqp::if() equivalents
  • readability of the core setting should be improved.

make test and make spectest clean.

If memory serves me well, about 1.5 years ago, optimizations in
Rakudo made the construct:

   42 ?? foo !! bar

equally fast as the nqp equivalent:

  nqp::if(42,foo,bar)

This commit converts all of the simple nqp::if() structures in the
core.c setting to their ternary equivalents.

- binary size of CORE.c.setting.moarvm file is unchanged (almost)
- speed should be on par with the nqp::if() equivalents
- readability of the core setting should be improved.

make test and make spectest clean.
Copy link
Contributor

@AlexDaniel AlexDaniel left a comment

Choose a reason for hiding this comment

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

Last time I checked there was still a consistent difference, even if minor. Maybe that's no longer true. Either way I find the readability improvement much more important. Looked through the changes and didn't find any accidental mistakes. Great work!

@lizmat lizmat merged commit b1912d9 into master Oct 26, 2020
@lizmat lizmat deleted the nqpif2ternary branch October 30, 2020 12:56
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.

None yet

2 participants