summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJoe Kain <[email protected]>2012-03-31 15:57:14 -0700
committerJoe Kain <[email protected]>2012-03-31 16:44:03 -0700
commit8190b1428774e0dac398d43e9c97e5476126073b (patch)
tree926db87a9dc208c2d729eba8375a42ba0d5d9731
parenta276aaebab11117a9c6c78f8bd9b2d44d07c3772 (diff)
downloadcaxlsx-8190b1428774e0dac398d43e9c97e5476126073b.tar.gz
caxlsx-8190b1428774e0dac398d43e9c97e5476126073b.zip
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
-rw-r--r--lib/axlsx/workbook/worksheet/cell.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb
index bfb7f35f..1b042994 100644
--- a/lib/axlsx/workbook/worksheet/cell.rb
+++ b/lib/axlsx/workbook/worksheet/cell.rb
@@ -225,7 +225,8 @@ module Axlsx
# 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