diff options
author | schneems <richard.schneeman+foo@gmail.com> | 2018-09-07 14:03:41 -0500 |
---|---|---|
committer | schneems <richard.schneeman+foo@gmail.com> | 2018-09-11 16:52:44 -0500 |
commit | 99d260298c3b70d70042c872841b5e81c938fd5b (patch) | |
tree | 849df22c67095a566f0270d4681701868a1e0d46 /activerecord/test/cases/reflection_test.rb | |
parent | 82ac7555ab69c1ae11360d2b9bd8dfd723a13485 (diff) | |
download | rails-99d260298c3b70d70042c872841b5e81c938fd5b.tar.gz rails-99d260298c3b70d70042c872841b5e81c938fd5b.tar.bz2 rails-99d260298c3b70d70042c872841b5e81c938fd5b.zip |
Move digest path calculation out of loop
On every iteration of generating a cache for a collection a “digest path” is calculated even though it’s exactly the same for every element.
This PR exposes a method `digest_path_from_virtual` that returns back a “digest_path”. This can in turn be passed back into `cache_fragment_name`. This not only does less work, but it also (you guessed it) uses less memory.
before: Total allocated: 762539 bytes (7035 objects)
after: Total allocated: 743590 bytes (6621 objects)
(762539 - 743590)/ 762539.0 # => 2.4% faster ⚡️⚡️
Diffstat (limited to 'activerecord/test/cases/reflection_test.rb')
0 files changed, 0 insertions, 0 deletions