Skip to content

Commit

Permalink
Merge pull request #963 from q-centrix/attribute-builder-change
Browse files Browse the repository at this point in the history
Rewrite old attribute mapping to save many object allocations
  • Loading branch information
amatsuda committed Oct 26, 2017
2 parents b41322e + 3bba452 commit 291a7a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
# Haml Changelog

* Performance/memory usage improvement in `lib/haml/buffer.rb` [#963](https://github.com/haml/haml/pull/963) (thanks [Dillon Welch](https://github.com/oniofchaos))
* Add erubis to gemspec so that `benchmark.rb` works [#964](https://github.com/haml/haml/pull/964) (thanks [Dillon Welch](https://github.com/oniofchaos))

## 5.0.4
Expand Down
4 changes: 3 additions & 1 deletion lib/haml/buffer.rb
Expand Up @@ -132,7 +132,9 @@ def adjust_tabs(tab_change)
def attributes(class_id, obj_ref, *attributes_hashes)
attributes = class_id
attributes_hashes.each do |old|
AttributeBuilder.merge_attributes!(attributes, Hash[old.map {|k, v| [k.to_s, v]}])
result = {}
old.each { |k, v| result[k.to_s] = v }
AttributeBuilder.merge_attributes!(attributes, result)
end
AttributeBuilder.merge_attributes!(attributes, parse_object_ref(obj_ref)) if obj_ref
AttributeBuilder.build_attributes(
Expand Down

0 comments on commit 291a7a7

Please sign in to comment.