Project

General

Profile

Actions

Patch #26721

closed

use find_by instead of detect

Added by jwjw yy over 6 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Code cleanup/refactoring
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

In project.rb

enable_module(name)
 enabled_modules.detect {|m| m.name == name}
end 

should be replaced by in order to only get the specified enabled_module instead of doing filtering after retrieving them all.

enabled_modules.find_by(name: name)

Files

project.rb.diff (472 Bytes) project.rb.diff jwjw yy, 2017-08-19 05:01
project.rb.2.diff (1.07 KB) project.rb.2.diff jwjw yy, 2017-08-19 05:27
project.rb.3.diff (2.32 KB) project.rb.3.diff jwjw yy, 2017-08-19 05:43
Actions #1

Updated by jwjw yy over 6 years ago

same situation for copy_issues

Actions #3

Updated by Toshi MARUYAMA over 6 years ago

  • Tracker changed from Defect to Patch
  • Description updated (diff)
  • Category set to Code cleanup/refactoring
  • Target version set to 4.1.0

Please don't use "Defect" tracker for not defect.
Please use code highlighting in description. It is too hard to read.

Actions #4

Updated by Pavel Rosický over 6 years ago

enabled_modules and versions are usually preloaded, so detect is more effective then find_by that will always trigger a new database query

Actions #5

Updated by Toshi MARUYAMA over 6 years ago

  • Status changed from New to Needs feedback
  • Target version deleted (4.1.0)
Actions #6

Updated by Go MAEDA almost 3 years ago

  • Status changed from Needs feedback to Closed

Pavel Rosický wrote:

enabled_modules and versions are usually preloaded, so detect is more effective then find_by that will always trigger a new database query

Closing.

Actions

Also available in: Atom PDF