summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/stylesheet/num_fmt.rb
diff options
context:
space:
mode:
authorPaul Kmiec <[email protected]>2023-04-29 16:24:22 -0700
committerPaul Kmiec <[email protected]>2023-05-15 23:36:40 -0700
commita4ba108eb33cba35f87370b7e4b47bff18130e89 (patch)
tree3ed38268770453feb0dca6407e4b42c94894f02a /lib/axlsx/stylesheet/num_fmt.rb
parent3b9ac17d8e4dc8b315ac307ffad6f2aa0cb96741 (diff)
downloadcaxlsx-a4ba108eb33cba35f87370b7e4b47bff18130e89.tar.gz
caxlsx-a4ba108eb33cba35f87370b7e4b47bff18130e89.zip
Serialize attributes more efficiently
The attributes in rows, cells, styles, etc are pre-defined for each type and almost never change. The current code, however, does not take that into account by reading all instance variables (via declared_attributes), filtering out the blank one and ones that are not xml attributes, and by camelizing each one. We can avoid all this extra work by computing the camels and ivars for xml attributes once and directly read the instance variables we care about.
Diffstat (limited to 'lib/axlsx/stylesheet/num_fmt.rb')
-rw-r--r--lib/axlsx/stylesheet/num_fmt.rb6
1 files changed, 1 insertions, 5 deletions
diff --git a/lib/axlsx/stylesheet/num_fmt.rb b/lib/axlsx/stylesheet/num_fmt.rb
index 1a7add0e..95d9a62b 100644
--- a/lib/axlsx/stylesheet/num_fmt.rb
+++ b/lib/axlsx/stylesheet/num_fmt.rb
@@ -75,11 +75,7 @@ module Axlsx
# Override to avoid removing underscores
def serialized_attributes(str = +'', additional_attributes = {})
- attributes = declared_attributes.merge! additional_attributes
- attributes.each do |key, value|
- str << "#{Axlsx.camel(key, false)}=\"#{Axlsx.booleanize(value)}\" "
- end
- str
+ super(str, additional_attributes, false)
end
end
end