Patch #26721
closed
use find_by instead of detect
Added by jwjw yy over 7 years ago.
Updated over 3 years ago.
Category:
Code cleanup/refactoring
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
same situation for copy_issues
- 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.
enabled_modules and versions are usually preloaded, so detect is more effective then find_by that will always trigger a new database query
- Status changed from New to Needs feedback
- Target version deleted (
4.1.0)
- 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.
Also available in: Atom
PDF