summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.rubocop_todo.yml11
-rw-r--r--lib/axlsx/util/simple_typed_list.rb6
-rw-r--r--lib/axlsx/workbook/worksheet/merged_cells.rb4
-rwxr-xr-xtest/benchmark.rb17
4 files changed, 22 insertions, 16 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index cd694c03..e536dd97 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -60,11 +60,6 @@ Lint/DisjunctiveAssignmentInConstructor:
Exclude:
- 'lib/axlsx/drawing/num_data_source.rb'
-# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
-Lint/DuplicateBranch:
- Exclude:
- - 'lib/axlsx/workbook/worksheet/merged_cells.rb'
-
Lint/NonLocalExitFromIterator:
Exclude:
- 'lib/axlsx/util/validators.rb'
@@ -159,12 +154,6 @@ Style/AccessorGrouping:
Style/Alias:
Enabled: false
-# This cop supports unsafe autocorrection (--autocorrect-all).
-# Configuration parameters: MinBranchesCount.
-Style/CaseLikeIf:
- Exclude:
- - 'lib/axlsx/workbook/worksheet/merged_cells.rb'
-
Style/ClassVars:
Exclude:
- 'lib/axlsx.rb'
diff --git a/lib/axlsx/util/simple_typed_list.rb b/lib/axlsx/util/simple_typed_list.rb
index c14aef03..30cfd2a5 100644
--- a/lib/axlsx/util/simple_typed_list.rb
+++ b/lib/axlsx/util/simple_typed_list.rb
@@ -15,6 +15,12 @@ module Axlsx
undef_method name
end
+ # We often call index(element) on instances of SimpleTypedList. Thus, we do not want to inherit Array
+ # implementation of == / eql? which walks the elements calling == / eql?. Instead we want the fast
+ # and original versions from BasicObject.
+ alias :== :equal?
+ alias :eql? :equal?
+
# Creats a new typed list
# @param [Array, Class] type An array of Class objects or a single Class object
# @param [String] serialize_as The tag name to use in serialization
diff --git a/lib/axlsx/workbook/worksheet/merged_cells.rb b/lib/axlsx/workbook/worksheet/merged_cells.rb
index c0ca1ebe..c3fb6dde 100644
--- a/lib/axlsx/workbook/worksheet/merged_cells.rb
+++ b/lib/axlsx/workbook/worksheet/merged_cells.rb
@@ -12,7 +12,7 @@ module Axlsx
end
# adds cells to the merged cells collection
- # @param [Array||String] cells The cells to add to the merged cells
+ # @param [Array|String] cells The cells to add to the merged cells
# collection. This can be an array of actual cells or a string style
# range like 'A1:C1'
def add(cells)
@@ -20,8 +20,6 @@ module Axlsx
cells
elsif cells.is_a?(Array)
Axlsx::cell_range(cells, false)
- elsif cells.is_a?(Row)
- Axlsx::cell_range(cells, false)
end
end
diff --git a/test/benchmark.rb b/test/benchmark.rb
index d5ccdf64..fb4d7050 100755
--- a/test/benchmark.rb
+++ b/test/benchmark.rb
@@ -11,9 +11,22 @@ input1 = (32..126).to_a.pack('U*').chars.to_a # these will need to be escaped
input2 = (65..122).to_a.pack('U*').chars.to_a # these do not need to be escaped
10.times { row << input1.shuffle.join }
10.times { row << input2.shuffle.join }
-times = 3000
+times = 3_000
Benchmark.bmbm(30) do |x|
+ x.report('axlsx_merged_cells') do
+ p = Axlsx::Package.new
+ p.workbook do |wb|
+ wb.add_worksheet do |sheet|
+ times.times do
+ sheet << row
+ sheet.merge_cells(sheet.rows.last.cells)
+ end
+ end
+ end
+ p.serialize("example_axlsx_merged_cells.xlsx")
+ end
+
x.report('axlsx_noautowidth') do
p = Axlsx::Package.new
p.workbook do |wb|
@@ -85,4 +98,4 @@ Benchmark.bmbm(30) do |x|
end
end
end
-File.delete("example.csv", "example_streamed.xlsx", "example_shared.xlsx", "example_autowidth.xlsx", "example_noautowidth.xlsx", "example_zip_command.xlsx")
+File.delete("example_axlsx_merged_cells.xlsx", "example.csv", "example_streamed.xlsx", "example_shared.xlsx", "example_autowidth.xlsx", "example_noautowidth.xlsx", "example_zip_command.xlsx")