summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorGeremia Taglialatela <[email protected]>2023-06-03 20:20:23 +0200
committerGeremia Taglialatela <[email protected]>2023-06-03 20:20:23 +0200
commit32e81f08a619291394e9eaacb42a2051535b2fd1 (patch)
treecc616c1da8153302eebade301d1a3f7dda775725 /lib
parentad87c51bf8c8f59a36514bb95dc6d3a582c6b2fd (diff)
downloadcaxlsx-32e81f08a619291394e9eaacb42a2051535b2fd1.tar.gz
caxlsx-32e81f08a619291394e9eaacb42a2051535b2fd1.zip
Avoid unnecessary calls to `parse_options`
`Cell#initialize` is one of the most used methods in the library, so a small improvement here will make a lot of difference on the overall performance. The impact of this change is negligible when `options` has elements but is substantial when it is empty. ``` Comparison (empty options): parse unless: 11636650.6 i/s parse: 8109825.4 i/s - 1.43x (± 0.00) slower Comparison (1 option): parse: 3548037.5 i/s parse unless: 3459029.7 i/s - same-ish: difference falls within error ```
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx/workbook/worksheet/cell.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb
index f651e3cb..3146bca4 100644
--- a/lib/axlsx/workbook/worksheet/cell.rb
+++ b/lib/axlsx/workbook/worksheet/cell.rb
@@ -48,7 +48,7 @@ module Axlsx
val = options.delete(:escape_formulas)
self.escape_formulas = val unless val.nil?
- parse_options(options)
+ parse_options(options) unless options.empty?
self.value = value
value.cell = self if contains_rich_text?