reserve capacity in toAppend<StringType>(...)
Summary:
I modified the toAppend(args..., StringType* dest) so that
before appending it reserves enough space for data to be appended. It is
still work in progress (floats and doubles are really bad: we only do
very naive approximation of the size). On float like workload we gain
~10% perf, on strings/ints/chars we gain as much as 25% of perf.
Probably on bigger strings it will be even faster. We only modify the
case when toAppend() has more than 1 element to append as it would be
just overhead in case of one argument.
Test Plan:
with this change:
============================================================================
folly/test/ConvTest.cpp relative time/iter
iters/s
============================================================================
preallocateTestNoFloat 1.59us 627.85K
preallocateTestFloat 1.09us 920.70K
----------------------------------------------------------------------------
============================================================================
without the change:
============================================================================
folly/test/ConvTest.cpp relative time/iter
iters/s
============================================================================
preallocateTestNoFloat 2.12us 471.43K
preallocateTestFloat 1.22us 818.25K
----------------------------------------------------------------------------
============================================================================
Reviewed By: marcelo.juchem@fb.com
FB internal diff:
D1420588
Tasks:
4632421