diff options
| author | Paul Kmiec <[email protected]> | 2023-05-05 08:58:17 -0700 |
|---|---|---|
| committer | Paul Kmiec <[email protected]> | 2023-05-05 09:29:58 -0700 |
| commit | 67aefd7705df82e43a8670102400a5abab49f6e8 (patch) | |
| tree | 6872755fccedb331f4553c72b642c6c86a700bff /lib/axlsx/drawing/cat_axis.rb | |
| parent | 1c355c83a9603f835dfe59ef4473df2b8cc3534c (diff) | |
| download | caxlsx-67aefd7705df82e43a8670102400a5abab49f6e8.tar.gz caxlsx-67aefd7705df82e43a8670102400a5abab49f6e8.zip | |
Pipe output directly to str and avoid additional memory allocations
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.
Diffstat (limited to 'lib/axlsx/drawing/cat_axis.rb')
| -rw-r--r-- | lib/axlsx/drawing/cat_axis.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/axlsx/drawing/cat_axis.rb b/lib/axlsx/drawing/cat_axis.rb index a36f62d1..2f40f29f 100644 --- a/lib/axlsx/drawing/cat_axis.rb +++ b/lib/axlsx/drawing/cat_axis.rb @@ -71,11 +71,11 @@ module Axlsx def to_xml_string(str = +'') str << '<c:catAx>' super(str) - str << (+'<c:auto val="' << @auto.to_s << '"/>') - str << (+'<c:lblAlgn val="' << @lbl_algn.to_s << '"/>') - str << (+'<c:lblOffset val="' << @lbl_offset.to_i.to_s << '"/>') - str << (+'<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>') - str << (+'<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>') + str << '<c:auto val="' << @auto.to_s << '"/>' + str << '<c:lblAlgn val="' << @lbl_algn.to_s << '"/>' + str << '<c:lblOffset val="' << @lbl_offset.to_i.to_s << '"/>' + str << '<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>' + str << '<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>' str << '</c:catAx>' end end |
