optimize for the common case: selecting only one tag

This commit is contained in:
Reinier Balt 2011-10-28 20:50:38 +02:00
parent 58d8bc56d1
commit bfb6c4ee9a

View file

@ -1028,6 +1028,9 @@ class TodosController < ApplicationController
end
def find_todos_with_tag_expr(tag_expr)
# optimize for the common case: selecting only one tag
return current_user.todos.with_tag(@tag_name) if @single_tag
tag_ids = get_ids_from_tag_expr(tag_expr)
todos = current_user.todos
tag_ids.each do |ids|