From 8190b1428774e0dac398d43e9c97e5476126073b Mon Sep 17 00:00:00 2001 From: Joe Kain Date: Sat, 31 Mar 2012 15:57:14 -0700 Subject: 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 --- lib/axlsx/workbook/worksheet/cell.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3