Skip to content

Commit

Permalink
5% performance increase when doing a SimpleTag#rendered_attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cohuman Developer committed Nov 18, 2011
1 parent aa06f35 commit 122eb5b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/renderers/simple_tag.rb
Expand Up @@ -32,13 +32,13 @@ def c(*args)


def rendered_attributes def rendered_attributes
str = "" str = ""
str << " class=\"#{css_class.join(' ')}\"" unless css_class.empty? str << " class=\"" << css_class.join(' ') << "\"" unless css_class.empty?
keys = attributes.keys.sort{|a, b| a.to_s <=> b.to_s} keys = attributes.keys.sort{|a, b| a.to_s <=> b.to_s}
keys.each do |key| keys.each do |key|
value = attributes[key] value = attributes[key]
if value if value
value = value.to_s.gsub('"', '\'') value = value.to_s.gsub('"', '\'')
str << " #{key}=\"#{value}\"" str << " " << key.to_s << "=\"" << value.to_s << "\""
end end
end end
str str
Expand Down

0 comments on commit 122eb5b

Please sign in to comment.