Closed sihlfall closed 1 year ago
Thanks a bunch, if you create a PR i'd be happy to apply it :) Else I could update it myself later 👍 Great work!
@sihlfall can you post your benchmark code here? I would like to take bite at it as well. Thanks.
@FlameHorizon See here:
https://github.com/sihlfall/vba-stringbuilder/tree/master/timing
Closed by #73
This is a great project! These classes save a lot of work.
Maybe my tweaking of StringBuilder is of interest to someone.
The StringBuilder class relies on string concatenation (repeated &), which results in a lot of string creation and copying. This can be overcome by using an exponentially growing buffer. Since I needed such a StringBuilder, I created one (https://github.com/sihlfall/vba-stringbuilder/).
I have been able to apply the ideas used there to stdVBA's StringBuilder class. In addition, I have modified StringBuilder to create the variable substitution dictionary lazily (so it is only created when it is actually used).
The modified class can be found here:
https://github.com/sihlfall/vba-stringbuilder/blob/master/comparison/stdvba-ssb/stdStringBuilderSsb.cls
It should, after renaming, be a drop-in replacement for the existing class.
Performance improvements are considerable. For instance, consider appending n single-character strings to an initial string of length 20,000:
For a larger initial string: