mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-18 00:00:12 +01:00
Fasterer: Parallel assignment is slower
Parallel assignment is slower than sequential assignment. Only got the low hanging fruit. There are some functions that have multiple return values. Fixing this needs more refactoring.
This commit is contained in:
parent
9f81e1a5c3
commit
5092b388fe
4 changed files with 63 additions and 47 deletions
|
|
@ -40,18 +40,21 @@ class TodosController < ApplicationController
|
||||||
cookies[:mobile_url]= { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
|
cookies[:mobile_url]= { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
|
||||||
determine_down_count
|
determine_down_count
|
||||||
|
|
||||||
render :action => 'index'
|
render :action => 'index'.freeze
|
||||||
end
|
end
|
||||||
format.text do
|
format.text do
|
||||||
# somehow passing Mime::TEXT using content_type to render does not work
|
# somehow passing Mime::TEXT using content_type to render does not work
|
||||||
headers['Content-Type']=Mime::TEXT.to_s
|
headers['Content-Type'.freeze]=Mime::TEXT.to_s
|
||||||
render :content_type => Mime::TEXT
|
render :content_type => Mime::TEXT
|
||||||
end
|
end
|
||||||
format.xml do
|
format.xml do
|
||||||
@xml_todos = params[:limit_to_active_todos] ? @not_done_todos : @todos
|
@xml_todos = params[:limit_to_active_todos] ? @not_done_todos : @todos
|
||||||
render :xml => @xml_todos.to_xml( *todo_xml_params )
|
render :xml => @xml_todos.to_xml( *todo_xml_params )
|
||||||
end
|
end
|
||||||
format.any(:rss, :atom) { @feed_title, @feed_description = 'Tracks Actions', "Actions for #{current_user.display_name}" }
|
format.any(:rss, :atom) do
|
||||||
|
@feed_title = 'Tracks Actions'.freeze
|
||||||
|
@feed_description = "Actions for #{current_user.display_name}"
|
||||||
|
end
|
||||||
format.ics
|
format.ics
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -156,7 +159,10 @@ class TodosController < ApplicationController
|
||||||
p = Todos::TodoCreateParamsHelper.new(params, current_user)
|
p = Todos::TodoCreateParamsHelper.new(params, current_user)
|
||||||
tag_list = p.tag_list
|
tag_list = p.tag_list
|
||||||
|
|
||||||
@not_done_todos, @build_todos, @todos, errors = [], [], [], []
|
@not_done_todos = []
|
||||||
|
@build_todos = []
|
||||||
|
@todos = []
|
||||||
|
errors = []
|
||||||
@predecessor = nil
|
@predecessor = nil
|
||||||
validates = true
|
validates = true
|
||||||
|
|
||||||
|
|
@ -887,13 +893,15 @@ class TodosController < ApplicationController
|
||||||
elsif params[:format].nil?
|
elsif params[:format].nil?
|
||||||
# if no format is given, default to html
|
# if no format is given, default to html
|
||||||
# note that if url has ?format=m, we should not overwrite it here
|
# note that if url has ?format=m, we should not overwrite it here
|
||||||
request.format, params[:format] = :html, :html
|
request.format = :html
|
||||||
|
params[:format] = :html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_format_for_tag_view(format)
|
def set_format_for_tag_view(format)
|
||||||
# tag name ends with .m, set format to :m en remove .m from name
|
# tag name ends with .m, set format to :m en remove .m from name
|
||||||
request.format, params[:format] = format, format
|
request.format = format
|
||||||
|
params[:format] = format
|
||||||
params[:name] = params[:name].chomp(".#{format.to_s}")
|
params[:name] = params[:name].chomp(".#{format.to_s}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ module ProjectsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_next_prev_mobile
|
def project_next_prev_mobile
|
||||||
prev_project,next_project= "", ""
|
prev_project = ""
|
||||||
|
next_project = ""
|
||||||
prev_project = content_tag(:li, link_to_project_mobile(@previous_project, "5", @previous_project.shortened_name), :class=>"prev") if @previous_project
|
prev_project = content_tag(:li, link_to_project_mobile(@previous_project, "5", @previous_project.shortened_name), :class=>"prev") if @previous_project
|
||||||
next_project = content_tag(:li, link_to_project_mobile(@next_project, "6", @next_project.shortened_name), :class=>"next") if @next_project
|
next_project = content_tag(:li, link_to_project_mobile(@next_project, "6", @next_project.shortened_name), :class=>"next") if @next_project
|
||||||
return content_tag(:ul, "#{prev_project}#{next_project}".html_safe, :class=>"next-prev-project")
|
return content_tag(:ul, "#{prev_project}#{next_project}".html_safe, :class=>"next-prev-project")
|
||||||
|
|
|
||||||
|
|
@ -101,8 +101,8 @@ module LoginSystem
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
http_user, http_pass = get_basic_auth_data
|
auth = get_basic_auth_data
|
||||||
if user = User.authenticate(http_user, http_pass)
|
if user = User.authenticate(auth[:user], auth[:pass])
|
||||||
session['user_id'] = user.id
|
session['user_id'] = user.id
|
||||||
set_current_user(user)
|
set_current_user(user)
|
||||||
return true
|
return true
|
||||||
|
|
@ -125,8 +125,8 @@ module LoginSystem
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
http_user, http_pass = get_basic_auth_data
|
auth = get_basic_auth_data
|
||||||
if user = User.authenticate(http_user, http_pass)
|
if user = User.authenticate(auth[:user], auth[:pass])
|
||||||
session['user_id'] = user.id
|
session['user_id'] = user.id
|
||||||
set_current_user(user)
|
set_current_user(user)
|
||||||
return true
|
return true
|
||||||
|
|
@ -188,17 +188,23 @@ module LoginSystem
|
||||||
'X-HTTP_AUTHORIZATION', 'HTTP_AUTHORIZATION']
|
'X-HTTP_AUTHORIZATION', 'HTTP_AUTHORIZATION']
|
||||||
|
|
||||||
authdata = nil
|
authdata = nil
|
||||||
for location in auth_locations
|
auth_locations.each do |location|
|
||||||
if request.env.has_key?(location)
|
if request.env.has_key?(location)
|
||||||
authdata = request.env[location].to_s.split
|
authdata = request.env[location].to_s.split
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if authdata and authdata[0] == 'Basic'
|
if authdata and authdata[0] == 'Basic'
|
||||||
user, pass = Base64.decode64(authdata[1]).split(':')[0..1]
|
data = Base64.decode64(authdata[1]).split(':')[0..1]
|
||||||
|
return {
|
||||||
|
user: data[0],
|
||||||
|
pass: data[1]
|
||||||
|
}
|
||||||
else
|
else
|
||||||
user, pass = ['', '']
|
return {
|
||||||
|
user: ''.freeze,
|
||||||
|
pass: ''.freeze
|
||||||
|
}
|
||||||
end
|
end
|
||||||
return user, pass
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def basic_auth_denied
|
def basic_auth_denied
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ module Tracks
|
||||||
def self.auto_link_message(text)
|
def self.auto_link_message(text)
|
||||||
text.gsub(AUTO_LINK_MESSAGE_RE) do
|
text.gsub(AUTO_LINK_MESSAGE_RE) do
|
||||||
href = $&
|
href = $&
|
||||||
left, right = $`, $'
|
left = $`
|
||||||
|
right = $'
|
||||||
# detect already linked URLs and URLs in the middle of a tag
|
# detect already linked URLs and URLs in the middle of a tag
|
||||||
if left =~ /<[^>]+$/ && right =~ /^[^>]*>/
|
if left =~ /<[^>]+$/ && right =~ /^[^>]*>/
|
||||||
# do not change string; URL is alreay linked
|
# do not change string; URL is alreay linked
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue