Patch #26726

collect(&:id) could be pluck(:id)

Added by jwjw yy 10 months ago. Updated 10 months ago.

Status:Needs feedbackStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Code cleanup/refactoring
Target version:-

Description

redmine/app/controllers/versions_controller.rb:37:        project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id]
redmine/app/controllers/versions_controller.rb:37:        project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id]
redmine/app/models/issue.rb:1383:    moved_project_ids = project.self_and_descendants.reload.collect(&:id)

could change collect to pluck

History

#1 Updated by Toshi MARUYAMA 10 months ago

  • Description updated (diff)
  • Category set to Code cleanup/refactoring
  • Status changed from New to Needs feedback

Please post by patch.

#2 Updated by Toshi MARUYAMA 10 months ago

And please describe why this change is effective.

#3 Updated by jwjw yy 10 months ago

Since pluck will only access the specific field but collect will retrieve every field of the object.

#4 Updated by Toshi MARUYAMA 10 months ago

Toshi MARUYAMA wrote:

Please post by patch.

Please post by attachment patch file.

Also available in: Atom PDF