Re: Is '?' really faster than '??'

[email protected]
Newsgroups gmane.comp.audio.supercollider.devel
Message-ID <[email protected]>
On November 5, 2017 00:52:26 julian.rohrhuber-QYZGCWsIODmAF8UT6DzBU6xOck334EZe@public.gmane.org wrote:

> thank you for doing these tests, James. Much better than fading memory.

I learned something too -- I honestly thought ? was a normal method call. I 
was surprised when it was performing about the same as the inlined 
short-circuiting operator. The ControlOpcode explains the result.

Part of the point is to be cautious about making style recommendations for 
the class library. If it were just a "huh, didn't expect that" curiosity, I 
might have passed it by. When it started being recommended, then some more 
evidence would be wise.

The really precise conclusion is, if it's a ? b (no method call):

- If you expect a to be nil most of the time, a ? b is, on average, very 
slightly faster.

- If you expect a to have a value most of the time, a ?? { b } is slightly 
faster.

- If it's 50-50, the speed differences cancel out.

... which is a lot for an average user to remember :D

hjh

Sent with AquaMail for Android
http://www.aqua-mail.com




_______________________________________________
sc-dev mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/
search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.