diff options
| author | Zsolt Kozaroczy <[email protected]> | 2023-06-09 10:58:23 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-06-09 10:58:23 +0200 |
| commit | cfb516062de3d0725b3245cc328f96d702d662d3 (patch) | |
| tree | aac97180441376a9696b73e82f7b2f7d6ce19766 /lib/axlsx/workbook/worksheet/cell.rb | |
| parent | de23c1204a4999f747740cd119b0f74247b2f9d5 (diff) | |
| parent | b429bd3e7509eafa3f72fb918e691bb8dacc7b19 (diff) | |
| download | caxlsx-cfb516062de3d0725b3245cc328f96d702d662d3.tar.gz caxlsx-cfb516062de3d0725b3245cc328f96d702d662d3.zip | |
Merge pull request #278 from tagliala/chore/invert-nil-checks
Invert nil checks to improve performance
Diffstat (limited to 'lib/axlsx/workbook/worksheet/cell.rb')
| -rw-r--r-- | lib/axlsx/workbook/worksheet/cell.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb index 3146bca4..b9f78fdb 100644 --- a/lib/axlsx/workbook/worksheet/cell.rb +++ b/lib/axlsx/workbook/worksheet/cell.rb @@ -177,12 +177,12 @@ module Axlsx # Indicates if the cell is good for shared string table def plain_string? - (type == :string || type == :text) && # String typed - !is_text_run? && # No inline styles - [email protected]? && # Not nil - [email protected]? && # Not empty - !is_formula? && # Not a formula - !is_array_formula? # Not an array formula + (type == :string || type == :text) && # String typed + !value.nil? && + !value.empty? && + !is_text_run? && # No inline styles + !is_formula? && + !is_array_formula? end # The inline font_name property for the cell @@ -426,7 +426,7 @@ module Axlsx # Attempts to determine the correct width for this cell's content # @return [Float] def autowidth - return if is_formula? || value.nil? + return if value.nil? || is_formula? if contains_rich_text? string_width('', font_size) + value.autowidth @@ -525,7 +525,7 @@ module Axlsx # About Time - Time in OOXML is *different* from what you might expect. The history as to why is interesting, but you can safely assume that if you are generating docs on a mac, you will want to specify Workbook.1904 as true when using time typed values. # @see Axlsx#date1904 def cast_value(v) - return v if v.is_a?(RichText) || v.nil? + return v if v.nil? || v.is_a?(RichText) case type when :date |
