mirror of
https://github.com/TracksApp/tracks.git
synced 2025-09-22 05:50:47 +02:00
Fasterer: Use &:symbol is faster
Calling argumentless methods within blocks is slower than using symbol to proc.
This commit is contained in:
parent
8a378aa2c4
commit
ddd9c07d3b
6 changed files with 51 additions and 51 deletions
|
@ -130,7 +130,7 @@ class ContextsController < ApplicationController
|
|||
# actions in the context will also be deleted.
|
||||
def destroy
|
||||
# make sure the deleted recurrence patterns are removed from associated todos
|
||||
@context.recurring_todos.each { |rt| rt.clear_todos_association } unless @context.recurring_todos.nil?
|
||||
@context.recurring_todos.each(&:clear_todos_association) unless @context.recurring_todos.nil?
|
||||
|
||||
@context.destroy
|
||||
respond_to do |format|
|
||||
|
|
|
@ -267,7 +267,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def destroy
|
||||
@project.recurring_todos.each {|rt| rt.remove_from_project!}
|
||||
@project.recurring_todos.each(&:remove_from_project!)
|
||||
@project.destroy
|
||||
|
||||
respond_to do |format|
|
||||
|
|
|
@ -188,7 +188,7 @@ class Todo < ActiveRecord::Base
|
|||
|
||||
def touch_predecessors
|
||||
self.touch
|
||||
predecessors.each { |p| p.touch_predecessors }
|
||||
predecessors.each(&:touch_predecessors)
|
||||
end
|
||||
|
||||
def removed_predecessors
|
||||
|
|
|
@ -162,7 +162,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
def test_text_feed_content_for_projects_with_no_actions
|
||||
login_as :admin_user
|
||||
p = projects(:timemachine)
|
||||
p.todos.each { |t| t.destroy }
|
||||
p.todos.each(&:destroy)
|
||||
|
||||
get :index, { :format => "txt", :only_active_with_no_next_actions => true }
|
||||
assert (/^\s*BUILD A WORKING TIME MACHINE\s+0 actions. Project is active.\s*$/.match(@response.body))
|
||||
|
|
|
@ -79,14 +79,14 @@ class ContextTest < ActiveSupport::TestCase
|
|||
@agenda.close!
|
||||
end
|
||||
|
||||
@agenda.todos.active.each {|t| t.complete! }
|
||||
@agenda.todos.active.each(&:complete!)
|
||||
@agenda.close!
|
||||
assert @agenda.closed?
|
||||
end
|
||||
|
||||
def test_activating_closed_context
|
||||
# given a context @agenda that is closed
|
||||
@agenda.todos.active.each {|t| t.complete! }
|
||||
@agenda.todos.active.each(&:complete!)
|
||||
@agenda.close!
|
||||
assert @agenda.closed?
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
assert !p.stalled?, "completed projects are not stalled"
|
||||
|
||||
p.activate!
|
||||
p.todos.each{|t| t.complete!}
|
||||
p.todos.each(&:complete!)
|
||||
assert p.todos.reload.active.empty?, "project should not have active todos"
|
||||
assert p.todos.reload.deferred_or_blocked.empty?, "there should not be deferred or blocked todos"
|
||||
assert p.reload.stalled?, "project should be stalled"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue