News for hackers. Stuff that matters.
Re:Ruby 2.3.0 Released by chrisseaton on Friday December 25, 2015 @10:19AM (#10791409)
'try' is relatively slow compared to other control logic, as allowing an exception to be thrown involves constructing an exception stack trace. This is slow in all VMs I know. Theoretically you could detect that the trace isn't used and remove it through escape analysis, but this is not easy, or you could do some crazy thing with lazily creating the stack trace, but that's a research project.
Re:Ruby 2.3.0 Released by hopsoft on Saturday December 26, 2015 @12:15AM (#10793357)
I wrote a script to benchmark some of the diff strategies for anyone curious. https://gist.github.com/hopsoft/ae361319c54bbcb4f8e2
Re:Ruby 2.3.0 Released by jrochkind1 on Friday December 25, 2015 @11:17AM (#10791536)
I think you are confused, `try` is not raise/rescue. The ActiveSupport `try` implementation does not involve allowing an exception to be raised.

https://github.com/rails/rails/blob/v4.2.5/activesupport/lib...

It should be as performant as other ways of checking for nil/empty.

Re:Ruby 2.3.0 Released by chrisseaton on Friday December 25, 2015 @11:29AM (#10791560)
Ah yes you're right - I was confusing this with raise/rescue.