@alex I am curious if the suggested code is optimized better by the JIT since you're not repeating the `===` comparison twice? Or maybe the JIT is smart enough to combine the left-hand side of those two statements?

1
Share
Share on Mastodon
Share on Twitter
Share on Facebook
Share on Linkedin
yopp

@postmodern you should have only single === call, inside the branch taken by “when” match.

godbolt.org/z/PK4azcP6G
godbolt.org/z/r73zebvaW

Diffidence in codepath is that fairly similar, but === case version have less indirection and getivar at the top. Dunno if this have any benefit for JIT.

I bet @tenderlove knows the answer!

1
10mo
Replies