rails/rails — pull request #8046 by pmahoney (2012-10-27 20:07:49+00:00)
Title: Replace flow-control exception with explicit test.

It was noticed while profiling 'assets:precompile' in JRuby that
exception creation was consuming a large portion of time, and
some of that was due to File.atomic_write.

Testing first with File.exists? eliminates the need for an exception
which should be a performance improvement on both JRuby and MRI.
In this case, the stat() isn't even extra overhead, since it is always
called anyway.

See some [benchmarks on exception vs stat overhead](http://polycrystal.org/2012/10/25/comparing_ruby_exceptions_to_additional_stat_test.html).