From 32e81f08a619291394e9eaacb42a2051535b2fd1 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Sat, 3 Jun 2023 20:20:23 +0200 Subject: Avoid unnecessary calls to `parse_options` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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 ``` --- lib/axlsx/workbook/worksheet/cell.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') 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? -- cgit v1.2.3