Eliminate extra template lookup in ActionView::Digestor #25826

Merged
merged 1 commit into from Jul 15, 2016

Projects

None yet

3 participants

@javan
Member
javan commented Jul 14, 2016 edited

PathSet#exists? and PathSet#find both do the same thing (PathSet#find_all). The exists? avoids MissingTemplate errors when no template is found. This change avoids it by using find_all.first instead. No behavior change, just one less template lookup.

Noticed this while working on #25411.

/cc @dhh @matthewd

@javan javan Eliminate extra template lookup in ActionView::Digestor
dbd3b0b
@javan javan added the actionview label Jul 14, 2016
@dhh
Member
dhh commented Jul 15, 2016

Sounds good to me. Any concerns @rafaelfranca ?

@rafaelfranca
Member

:shipit: . We may want to change the API of PathSet to have a find and find! method so we don't raise an exception by default when trying to find the first template. But that can be a future refactoring.

@rafaelfranca rafaelfranca merged commit d41d7a4 into rails:master Jul 15, 2016

2 checks passed

codeclimate Code Climate didn't find any new or fixed issues.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@rafaelfranca
Member

Backported in 0ef05cd

@javan
Member
javan commented Jul 15, 2016

❤️

We may want to change the API of PathSet to have a find and find!

That was my instinct too and I agree it should be a separate change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment