Permalink
Browse files

Build self_hash up from INLINE_STYLES

Iterate over each value in INLINE_STYLES instead of iterating over
each value in instances_values and rejecting unwanted items.  This
version proceses fewer values and runs a little faster.

Issue #61 - Axlsx performance
  • Loading branch information...
1 parent a276aae commit 8190b1428774e0dac398d43e9c97e5476126073b @joekain joekain committed Mar 31, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/axlsx/workbook/worksheet/cell.rb
View
3 lib/axlsx/workbook/worksheet/cell.rb
@@ -225,7 +225,8 @@ def initialize(row, value="", options={})
# equality comparison to test value, type and inline style attributes
# this is how we work out if the cell needs to be added or already exists in the shared strings table
def shareable_hash
- self_hash = self.instance_values.reject { |key, val| !INLINE_STYLES.include?(key) }
+ self_hash = {}
+ INLINE_STYLES.each { |style| self_hash[style] = self.instance_variable_get("@" + style) }
self_hash['color'] = self_hash['color'].instance_values if self_hash['color']
self_hash
end

0 comments on commit 8190b14

Please sign in to comment.