summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/workbook/worksheet/pivot_table.rb
diff options
context:
space:
mode:
authorGeremia Taglialatela <[email protected]>2023-06-15 09:20:31 +0200
committerGeremia Taglialatela <[email protected]>2023-06-15 09:20:31 +0200
commit9e5bc61c60f8775150163d6d2da73d60083f0dbd (patch)
treedccab6808cde0975e2cd32f69e234b3394b36b3e /lib/axlsx/workbook/worksheet/pivot_table.rb
parentad87c51bf8c8f59a36514bb95dc6d3a582c6b2fd (diff)
downloadcaxlsx-9e5bc61c60f8775150163d6d2da73d60083f0dbd.tar.gz
caxlsx-9e5bc61c60f8775150163d6d2da73d60083f0dbd.zip
Fix Lint/UnusedBlockArgument offenses
Use `each_value` instead of `each` where possible. The performance gain is minimal (3%). ``` Comparison: each_value: 4105733.4 i/s each: 3998011.4 i/s - 1.03x (± 0.00) slower ```
Diffstat (limited to 'lib/axlsx/workbook/worksheet/pivot_table.rb')
-rw-r--r--lib/axlsx/workbook/worksheet/pivot_table.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/axlsx/workbook/worksheet/pivot_table.rb b/lib/axlsx/workbook/worksheet/pivot_table.rb
index a75842cd..97c4515b 100644
--- a/lib/axlsx/workbook/worksheet/pivot_table.rb
+++ b/lib/axlsx/workbook/worksheet/pivot_table.rb
@@ -210,7 +210,7 @@ module Axlsx
end
str << '</rowFields>'
str << '<rowItems count="' << rows.size.to_s << '">'
- rows.size.times do |i|
+ rows.size.times do
str << '<i/>'
end
str << '</rowItems>'
@@ -220,7 +220,7 @@ module Axlsx
str << '<colFields count="1"><field x="-2"/></colFields>'
str << "<colItems count=\"#{data.size}\">"
str << '<i><x/></i>'
- data[1..-1].each_with_index do |datum_value, i|
+ (data.size - 1).times do |i|
str << "<i i=\"#{i + 1}\"><x v=\"#{i + 1}\"/></i>"
end
str << '</colItems>'