Skip to content

Commit b7e2bc0

Browse files
committed
Memoize resource relationships
bin/bench_regression "version": "0.10.0.rc5", "rails_version": "4.2.6", "benchmark_run[environment]": "2.2.2p95", perf/only_calc_associations_once "commit_hash": "1e7c428", caching on: caching serializers: gc off 741.7702402782281/ips; 1355 objects caching on: non-caching serializers: gc off 712.3752615532874/ips; 1257 objects caching off: caching serializers: gc off 706.0789199312495/ips; 1355 objects caching off: non-caching serializers: gc off 751.5310710635379/ips; 1257 objects master "commit_hash": "1033b711c7d7c231bb5b832e7dfe7f99389f22c4" caching on: caching serializers: gc off 567.7959835633892/ips; 1803 objects caching on: non-caching serializers: gc off 776.4929551133658/ips; 1257 objects caching off: caching serializers: gc off 538.046851190591/ips; 1803 objects caching off: non-caching serializers: gc off 738.5596630209004/ips; 1257 objects
1 parent 4c0e2dc commit b7e2bc0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/active_model_serializers/adapter/attributes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def serializable_hash_for_single_resource(options)
3434
def resource_relationships(options)
3535
relationships = {}
3636
serializer.associations(@include_tree).each do |association|
37-
relationships[association.key] = relationship_value_for(association, options)
37+
relationships[association.key] ||= relationship_value_for(association, options)
3838
end
3939

4040
relationships

0 commit comments

Comments
 (0)