[PATCH] D90386: [ADT] Add methods to SmallString for efficient concatenation

Nathan James via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 29 15:16:56 PDT 2020


njames93 added a comment.

In D90386#2362769 <https://reviews.llvm.org/D90386#2362769>, @dblaikie wrote:

> Could you refresh my memory on whether reserve has the same growth semantics as other size-increasing operations? I'm slightly concerned that if reserve only reserves the exact amount required (compared to an append or similar operation exceeding the capacity which would/should cause the usual multiplication factor growth) that this change as-is might hinder performance (eg: a loop that appends two things today would be getting the multiplicative growth - but then if it ends up with a reserve(size of two strings) call in it maybe it keeps only growing just enough on each loop iteration, incurring more growths?)?

Reserve and grow call the same function to actually grow the container, they both use the next power of 2 above the requested size. Reserve also won't allocate if it already has the capacity needed


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90386/new/

https://reviews.llvm.org/D90386



More information about the llvm-commits mailing list