| Age | Commit message (Collapse) | Author |
|
Fix Performance/StringIdentifierArgument offense
|
|
Cache `col_ref` and `row_ref`
|
|
|
|
Improve escape formulas
|
|
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
```
|
|
We still need Style/OptionalBooleanParameter as Ruby 2.7.5
gets confused with,
```
def serialized_attributes(str = +'', additional_attributes = {}, camelize_value: true)
```
|
|
The `booleanize` method is always used to pipe values
to str, so it is safe to return the boolean values as
strings.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
Co-authored-by: Geremia Taglialatela <[email protected]>
|
|
There are 2 offenses left but they would be breaking backwards
compatibility.
|
|
This avoid parse_options doing anything which can be expensive if it
happens for each cell.
|
|
The `row_ref` method is called once for each column in a row and once at the
row level.
|
|
|
|
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`
|
|
Fix a couple of performance RuboCop offenses in workbook
|
|
|
|
Fix Inefficient Hash Search offenses
|
|
SimpleTypedList subclass of Array
|
|
Fix minimum supported Ruby version in Readme
|
|
Ref: #214
[ci skip]
|
|
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.
|
|
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
```
|
|
Use `key?` instead of `keys.include?` to improve performance
|
|
Validation improvements
|
|
reduce memory consumption
|
|
Pipe directly to output
|
|
|
|
```
%> 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.
|
|
|
|
Zip::OutputStream
The BufferedZipOutputStream is a drop-in replacement for Zip::OutputStream similar
to ZipCommand.
|
|
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.
|
|
Added zip_command variant to benchmark.rb and added profile_memory.rb based on
the `memory_profiler` gem.
|
|
Frozen strings
|
|
Co-authored-by: Geremia Taglialatela <[email protected]>
|
|
|
|
Fix Layout/HeredocIndentation offenses
|
|
|
|
|
|
Also use `XML` as delimiter to highlight syntax in supported editors
|
|
Introduce RuboCop performance
|
|
tagliala/chore/fix-minor-safe-offenses-to-production-code
Fix safe, minor offenses to production code
|
|
|
|
Also fixes performance offences in non-production code
|
|
- Lint/RedundantStringCoercion
- Style/CommentAnnotation offenses
- Style/DefWithParentheses
- Style/EvalWithLocation
- Style/MethodCallWithoutArgsParentheses
- Style/MethodDefParentheses
- Style/NilComparison
- Style/Semicolon
|
|
Fix offenses to non-production code
|
|
|
|
Show links to style guide and RuboCop documentation
|