diff options
author | Chris Lattner <sabre@nondot.org> | 2007-08-10 07:02:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-08-10 07:02:50 +0000 |
commit | 4f155b4c8597f40a79add430dfedb2c08ba28375 (patch) | |
tree | 7cea96f18ab657b2508f73db7ae09bd9aa98ef2c /include/llvm/ADT | |
parent | 02cee38647ea413e5d05f29f67a7f003db9f0081 (diff) | |
download | external_llvm-4f155b4c8597f40a79add430dfedb2c08ba28375.zip external_llvm-4f155b4c8597f40a79add430dfedb2c08ba28375.tar.gz external_llvm-4f155b4c8597f40a79add430dfedb2c08ba28375.tar.bz2 |
memcpy with zero length is hugely expensive, so avoid it. This speeds up coallescing from 1.17s to 0.88s on siod.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40984 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT')
-rw-r--r-- | include/llvm/ADT/SmallVector.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index 1c970a5..e6c81a6 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -380,7 +380,11 @@ SmallVectorImpl<T>::operator=(const SmallVectorImpl<T> &RHS) { unsigned CurSize = unsigned(size()); if (CurSize >= RHSSize) { // Assign common elements. - iterator NewEnd = std::copy(RHS.Begin, RHS.Begin+RHSSize, Begin); + iterator NewEnd; + if (RHSSize) + NewEnd = std::copy(RHS.Begin, RHS.Begin+RHSSize, Begin); + else + NewEnd = Begin; // Destroy excess elements. destroy_range(NewEnd, End); |