Project

General

Profile

Actions

Patch #21582

closed

Performance in User#roles_for_project

Added by Ondřej Ezr over 8 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
Category:
Performance
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

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


Files

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

Updated by Go MAEDA about 8 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
Actions #2

Updated by Ondřej Ezr about 8 years ago

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

Actions #3

Updated by Go MAEDA about 8 years ago

Thanks for your feedback. Nice eureka!

Actions #4

Updated by Jean-Philippe Lang about 8 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.

Actions

Also available in: Atom PDF