|
From: Joshua J. <ja...@gm...> - 2018-05-02 21:32:10
|
Hi,
Has there been any discussion about quickfix.Message::toString() using a
ThreadLocal StringBuilder instead of a heap allocated StringBuilder()? For
large volume fix users I would think reusing a StringBuilder (which would
quickly grow to an optimal size since I imagine most fix msgs are close in
size) would be be a net positive.
I was thinking of just rolling a custom for our use, something like:
--- [snip] ---
class Message
{
...
final ThreadLocal<StringBuilder> tlsb = new ThreadLocal<StringBuilder>() {
@Override
public StringBuilder initialValue()
{
return new StringBuilder();
}
};
...
@Override
public String toString() {
...
final StringBuilder sb = tlsb.get();
sb.setLength(0);
header.calculate(sb, null, null);
...
}
--- [/snip] ---
Seems however that maybe this would be desired by others so maybe this
might be a good change to give back to the community. I imagine there might
be those who want/need to have the heap allocated StringBuilder so maybe
setting this behavior per Session would be the way to go.
Thoughts?
Josh
|