summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/SmallVector.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-08-10 07:02:50 +0000
committerChris Lattner <sabre@nondot.org>2007-08-10 07:02:50 +0000
commit4f155b4c8597f40a79add430dfedb2c08ba28375 (patch)
tree7cea96f18ab657b2508f73db7ae09bd9aa98ef2c /include/llvm/ADT/SmallVector.h
parent02cee38647ea413e5d05f29f67a7f003db9f0081 (diff)
downloadllvm-4f155b4c8597f40a79add430dfedb2c08ba28375.tar.gz
llvm-4f155b4c8597f40a79add430dfedb2c08ba28375.tar.bz2
llvm-4f155b4c8597f40a79add430dfedb2c08ba28375.tar.xz
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/SmallVector.h')
-rw-r--r--include/llvm/ADT/SmallVector.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h
index 1c970a5598..e6c81a6420 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);