diff options
| author | Geremia Taglialatela <[email protected]> | 2023-05-10 17:25:51 +0200 |
|---|---|---|
| committer | Geremia Taglialatela <[email protected]> | 2023-05-10 17:25:51 +0200 |
| commit | 7139d6252ad775ea9b6ffe2b2372e86c1c825401 (patch) | |
| tree | 1402fc2368cf9245459db84b1c6700ad0ce6f971 /lib/axlsx/drawing | |
| parent | 67d8a1a781e53761a483575cc5abc7e9a992d2ca (diff) | |
| download | caxlsx-7139d6252ad775ea9b6ffe2b2372e86c1c825401.tar.gz caxlsx-7139d6252ad775ea9b6ffe2b2372e86c1c825401.zip | |
Fix Inefficient Hash Search offenses
Use `key?` instead of `keys.include?` to improve performance
Diffstat (limited to 'lib/axlsx/drawing')
| -rw-r--r-- | lib/axlsx/drawing/axes.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/drawing/d_lbls.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/axlsx/drawing/axes.rb b/lib/axlsx/drawing/axes.rb index eb4728c6..6a74c879 100644 --- a/lib/axlsx/drawing/axes.rb +++ b/lib/axlsx/drawing/axes.rb @@ -9,7 +9,7 @@ module Axlsx # class of the axis type to construct. The :cat_axis, if there is one, # must come first (we assume a Ruby 1.9+ Hash or an OrderedHash). def initialize(options = {}) - raise(ArgumentError, "CatAxis must come first") if options.keys.include?(:cat_axis) && options.keys.first != :cat_axis + raise(ArgumentError, "CatAxis must come first") if options.key?(:cat_axis) && options.keys.first != :cat_axis options.each do |name, axis_class| add_axis(name, axis_class) diff --git a/lib/axlsx/drawing/d_lbls.rb b/lib/axlsx/drawing/d_lbls.rb index 4e2bd40c..29697378 100644 --- a/lib/axlsx/drawing/d_lbls.rb +++ b/lib/axlsx/drawing/d_lbls.rb @@ -76,7 +76,7 @@ module Axlsx str << '<c:dLbls>' instance_vals = Axlsx.instance_values_for(self) %w(d_lbl_pos show_legend_key show_val show_cat_name show_ser_name show_percent show_bubble_size show_leader_lines).each do |key| - next unless instance_vals.keys.include?(key) && instance_vals[key] != nil + next unless instance_vals.key?(key) && instance_vals[key] != nil str << "<c:#{Axlsx::camel(key, false)} val='#{instance_vals[key]}' />" end |
