diff options
| author | Geremia Taglialatela <[email protected]> | 2023-05-22 18:10:10 +0200 |
|---|---|---|
| committer | Geremia Taglialatela <[email protected]> | 2023-05-22 18:10:10 +0200 |
| commit | 3b4fc2bfaa6563d071322de21434aeae6eff9d8a (patch) | |
| tree | 5bca4235d1be7d92f23e225e8ed59b3e9c3758ba /lib/axlsx/drawing/axes.rb | |
| parent | 6752225bbb8a9eec905ec02a98f1a25a309c404a (diff) | |
| download | caxlsx-3b4fc2bfaa6563d071322de21434aeae6eff9d8a.tar.gz caxlsx-3b4fc2bfaa6563d071322de21434aeae6eff9d8a.zip | |
Fix safe class comparison offenses
Fixes:
- Style/ClassCheck
- Style/ClassEqualityComparison
While `is_a?` and `kind_of?` are equivalent, there is a 5% gain
when switching from class comparison to `intance_of?`
```
Comparison:
instance_of: 16902635.9 i/s
class comparison: 16061288.3 i/s - 1.05x (± 0.00) slower
```
Diffstat (limited to 'lib/axlsx/drawing/axes.rb')
| -rw-r--r-- | lib/axlsx/drawing/axes.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/axlsx/drawing/axes.rb b/lib/axlsx/drawing/axes.rb index 6a74c879..010fe8cd 100644 --- a/lib/axlsx/drawing/axes.rb +++ b/lib/axlsx/drawing/axes.rb @@ -32,7 +32,7 @@ module Axlsx def to_xml_string(str = +'', options = {}) if options[:ids] # CatAxis must come first in the XML (for Microsoft Excel at least) - sorted = axes.sort_by { |name, axis| axis.kind_of?(CatAxis) ? 0 : 1 } + sorted = axes.sort_by { |name, axis| axis.is_a?(CatAxis) ? 0 : 1 } sorted.each { |axis| str << '<c:axId val="' << axis[1].id.to_s << '"/>' } else axes.each { |axis| axis[1].to_xml_string(str) } |
