summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)Author
2023-05-17Merge pull request #228 from tagliala/chore/fix-string-identifier-argumentZsolt Kozaroczy
Fix Performance/StringIdentifierArgument offense
2023-05-17Merge pull request #227 from pkmiec/cacheColRefZsolt Kozaroczy
Cache `col_ref` and `row_ref`
2023-05-17Merge branch 'master' into cacheColRefZsolt Kozaroczy
2023-05-16Merge pull request #225 from pkmiec/improveEscapeFormulasNoel Peden
Improve escape formulas
2023-05-16Replace `sub` with `delete_prefix`/`delete_suffix`Geremia Taglialatela
Ruby 2.5 introduced `delete_prefix` and `delete_suffix`. Those methods are helpful when serializing formula and array formula values, that are supposed to start and end with given prefixes Also moves formula prefix to constants so they can be used by both `Cell` and `CellSerializer` classes Formula: ``` Ruby version: 3.2.2 Comparison: delete_prefix: 8759353.5 i/s sub: 2607022.4 i/s - 3.36x (± 0.00) slower Comparison: delete_prefix: 40 allocated sub: 160 allocated - 4.00x more ``` Array Formula: ``` Ruby version: 3.2.2 Comparison: delete_prefixes: 4798837.8 i/s sub_sub: 937072.1 i/s - 5.12x (± 0.00) slower Comparison: delete_prefixes: 120 allocated sub_sub: 488 allocated - 4.07x more ```
2023-05-15Fix rubocop offensesPaul Kmiec
We still need Style/OptionalBooleanParameter as Ruby 2.7.5 gets confused with, ``` def serialized_attributes(str = +'', additional_attributes = {}, camelize_value: true) ```
2023-05-15Booleanize as string instead of 0 / 1 only to call to_sPaul Kmiec
The `booleanize` method is always used to pipe values to str, so it is safe to return the boolean values as strings.
2023-05-15Serialize attributes more efficientlyPaul Kmiec
The attributes in rows, cells, styles, etc are pre-defined for each type and almost never change. The current code, however, does not take that into account by reading all instance variables (via declared_attributes), filtering out the blank one and ones that are not xml attributes, and by camelizing each one. We can avoid all this extra work by computing the camels and ivars for xml attributes once and directly read the instance variables we care about.
2023-05-15Remove ability to set `u=` to true in favor of :singlePaul Kmiec
The `u=` would convert `true` to `:single` for backwards compatibility. However, it is more explicit to set it to `:single` or one of the other underline options instead of relying on the conversion.
2023-05-15Only define @escape_formulas in cell if it is different from worksheetPaul Kmiec
The benchmarks showed that validate_boolean is called 200_005 times and almost all of those are to validate escape_formulas passed into cell. In this commit the worksheet does not pass in its escape_formulas value, avoiding validate_boolean, and instead the cell asks the worksheet for value when needed. Now validate_boolean is called 5 times in benchmarks.
2023-05-15Improve boolean validation constants (i.e. Axlsx::VALID_BOOLEAN_VALUES)Paul Kmiec
Added VALID_BOOLEAN_TRUE_VALUES and VALID_BOOLEAN_FALSE_VALUES so that those can be re-used in other placed and have the same notion of what a valid boolean value is. For example, we can use the true values in `Cell#u=`. Additionally, since validate_boolean / BOOLEAN_VALIDATOR are invoked so frequently, putting the likely values at the front can actually make a non-trivial difference. Since VALID_BOOLEAN_VALUES is derived from VALID_BOOLEAN_TRUE_VALUES and VALID_BOOLEAN_FALSE_VALUES, we use `Array#zip` to still end up with good order.
2023-05-15Using `between?` is more efficient than `cover?`Paul Kmiec
Co-authored-by: Geremia Taglialatela <[email protected]>
2023-05-15Fix safe rubocop offenses in Axslx::CellPaul Kmiec
There are 2 offenses left but they would be breaking backwards compatibility.
2023-05-15Treat escape_formulas similar to type, style, formula_valuePaul Kmiec
This avoid parse_options doing anything which can be expensive if it happens for each cell.
2023-05-15Also cache row_refPaul Kmiec
The `row_ref` method is called once for each column in a row and once at the row level.
2023-05-15Corrected rubocop offenses in lib/axlsx.rb / test/tc_axlsx.rbPaul Kmiec
2023-05-15Cache col_ref to avoid allocationsPaul Kmiec
In cases with lots of rows, each column will ask for its col_ref which will always be the same for the same column_index. We can cache this to avoid lots of small string allocations. Modified `CellSerializer` to use `#col_ref` and `#row_ref` avoiding the string allocation caused by `#col_r`
2023-05-15Use `include?` and `find` for performanceGeremia Taglialatela
Fix a couple of performance RuboCop offenses in workbook
2023-05-15Fix Performance/StringIdentifierArgument offenseGeremia Taglialatela
2023-05-15Merge pull request #224 from tagliala/chore/fix-inefficient-hash-searchZsolt Kozaroczy
Fix Inefficient Hash Search offenses
2023-05-15Merge pull request #223 from pkmiec/simpleTypedListAsArrayZsolt Kozaroczy
SimpleTypedList subclass of Array
2023-05-15Merge pull request #226 from tagliala/chore/fix-typo-in-readmeZsolt Kozaroczy
Fix minimum supported Ruby version in Readme
2023-05-13Fix minimum supported Ruby version in ReadmeGeremia Taglialatela
Ref: #214 [ci skip]
2023-05-10Fix `SimpleTypedList#to_a` and `SimpleTypedList#to_ary` returning the ↵Paul Kmiec
internal list instance The `to_a` and `to_ary` now work more like standard Array methods with `to_a` returning a new array containing the elements of self and `to_ary` returning self.
2023-05-10Derive SimpleTypedList from ArrayPaul Kmiec
Currently the SimpleTypedList is wrapping `@list` Array and re-implementing certain methods to add type / value checking and delegating all the non-destrutive methods to the internal @list. Most everything that ends up being serialized to the excel file is derived from SimpleTypedList (for example, a Row is a SimpleTypedList of Cells). This means that many of the delegated methods are hit over and over again especially `[]`. This extra delegation really adds up. We can avoid the delegation by having SimpleTypedList extend Array and still remove any un-safe methods. It is possible to re-introduce an unsafe method in a subclass of SimpleTypedList if needed. Here is one way, ```ruby class MyList < SimpleTypedList def clear @clear_method ||= Array.instance_method(:clear).bind(self) @clear_method.call end end ```
2023-05-10Fix Inefficient Hash Search offensesGeremia Taglialatela
Use `key?` instead of `keys.include?` to improve performance
2023-05-10Merge pull request #217 from kiskoza/validation-improvementsZsolt Kozaroczy
Validation improvements
2023-05-10Move definition of valid values and validator lambdas out of the methods to ↵Koza
reduce memory consumption
2023-05-10Merge pull request #220 from pkmiec/pipeDirectlyToOutputZsolt Kozaroczy
Pipe directly to output
2023-05-09Do not change the whitespace that is produced by to_xml_string'sPaul Kmiec
2023-05-07Regenerated rubocop todosPaul Kmiec
``` %> rubocop --auto-gen-config --no-auto-gen-timestamp --no-offense-counts ``` May need to rebase / resolve conlicts when https://github.com/caxlsx/caxlsx/pull/222 is merged.
2023-05-05Write directly to file io instead of buffering the output in memoryPaul Kmiec
2023-05-05Introduce BufferedZipOutputStream to avoid lots of small writes to ↵Paul Kmiec
Zip::OutputStream The BufferedZipOutputStream is a drop-in replacement for Zip::OutputStream similar to ZipCommand.
2023-05-05Pipe output directly to str and avoid additional memory allocationsPaul Kmiec
Currently, there are lots of examples of code like this, ``` str << ('<tag ' << foo << ' ' << bar << '/>') ``` which create the string for the tag in memory before piping to str. We can avoid creating all of these intermediate strings by dropping the paranthesis and piping directly to str. This relies on the `str` passed around to handle lots of small appends. This is a problem when using RubyZip, but that is solved in the next commit.
2023-05-05Improve benchmarking / profilingPaul Kmiec
Added zip_command variant to benchmark.rb and added profile_memory.rb based on the `memory_profiler` gem.
2023-05-05Merge pull request #219 from pkmiec/frozenStringsZsolt Kozaroczy
Frozen strings
2023-05-05Revert changelogZsolt Kozaroczy
Co-authored-by: Geremia Taglialatela <[email protected]>
2023-05-05Merge branch 'master' into frozenStringsZsolt Kozaroczy
2023-05-05Merge pull request #218 from tagliala/chore/rubocop-production-stage-iiZsolt Kozaroczy
Fix Layout/HeredocIndentation offenses
2023-05-04Fix tests / code to work with frozen string literalsPaul Kmiec
2023-05-04Enable Style/FrozenStringLiteralComment and autocorrectPaul Kmiec
2023-05-04Fix Layout/HeredocIndentation offensesGeremia Taglialatela
Also use `XML` as delimiter to highlight syntax in supported editors
2023-05-04Merge pull request #216 from tagliala/chore/introduce-rubocop-performanceZsolt Kozaroczy
Introduce RuboCop performance
2023-05-04Merge pull request #215 from ↵Zsolt Kozaroczy
tagliala/chore/fix-minor-safe-offenses-to-production-code Fix safe, minor offenses to production code
2023-05-03Fix unescaped dot in regexp and convert to includeGeremia Taglialatela
2023-05-03Introduce RuboCop performanceGeremia Taglialatela
Also fixes performance offences in non-production code
2023-05-03Fix safe, minor offenses to production codeGeremia Taglialatela
- Lint/RedundantStringCoercion - Style/CommentAnnotation offenses - Style/DefWithParentheses - Style/EvalWithLocation - Style/MethodCallWithoutArgsParentheses - Style/MethodDefParentheses - Style/NilComparison - Style/Semicolon
2023-05-03Merge pull request #204 from tagliala/chore/add-rubocop-stage-ii-testsNoel Peden
Fix offenses to non-production code
2023-05-03Fix Style/MapToHash offense (unsafe)Geremia Taglialatela
2023-05-03Improve RuboCop configGeremia Taglialatela
Show links to style guide and RuboCop documentation