Patch #21582

Performance in User#roles_for_project

Added by Ondřej Ezr almost 3 years ago. Updated over 2 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Performance
Target version:3.3.0

Description

roles are duplicating a scope not an result, thus every hit produce a query, cached, but it is still not desired.

roles_duping_scope.diff Magnifier - dup ary not scope (450 Bytes) Ondřej Ezr, 2015-12-22 00:32

Associated revisions

Revision 15060
Added by Jean-Philippe Lang over 2 years ago

Performance in User#roles_for_project (#21582).

Patch by by Ondřej Ezr.

History

#1 Updated by Go MAEDA over 2 years ago

  • Target version set to 3.3.0

I think we can remove the last 'dup' method from Ondřej Ezr's patch because ActiveRecord::Associations::CollectionProxy#to_a returns copied objects.

# File activerecord/lib/active_record/associations/collection_proxy.rb, line 943
      def to_ary
        load_target.dup
      end

#2 Updated by Ondřej Ezr over 2 years ago

true, I just put to_a there with heureka feeling, but you are right dup is meaningless now :)

#3 Updated by Go MAEDA over 2 years ago

Thanks for your feedback. Nice eureka!

#4 Updated by Jean-Philippe Lang over 2 years ago

  • Subject changed from Performance in roles to Performance in User#roles_for_project
  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang

Committed, thanks.

Also available in: Atom PDF