summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-11-28 22:17:14 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-11-28 22:17:14 +0000
commit08d55342e337fd4e80a68b81b8b0cbb100ea0a23 (patch)
tree73ff9f0d7f47e3221570fa9a4239429c0ac125e1 /include
parent5f456cda98c57b6dea8bc716978b69776d0d0e8f (diff)
downloadllvm-08d55342e337fd4e80a68b81b8b0cbb100ea0a23.tar.gz
llvm-08d55342e337fd4e80a68b81b8b0cbb100ea0a23.tar.bz2
llvm-08d55342e337fd4e80a68b81b8b0cbb100ea0a23.tar.xz
Don't use std::copy and std::copy_backward, run 10% faster.
Sometimes std::copy can become a memmove call, and that is not a good idea when copying relatively few bytes as we are doing. We also get a small win by changing two loops into one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120265 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/ADT/IntervalMap.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/include/llvm/ADT/IntervalMap.h b/include/llvm/ADT/IntervalMap.h
index d0a3b53087..b0a0a0ba9a 100644
--- a/include/llvm/ADT/IntervalMap.h
+++ b/include/llvm/ADT/IntervalMap.h
@@ -103,7 +103,6 @@
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/RecyclingAllocator.h"
-#include <limits>
#include <iterator>
// FIXME: Remove debugging code.
@@ -211,8 +210,10 @@ public:
unsigned j, unsigned Count) {
assert(i + Count <= M && "Invalid source range");
assert(j + Count <= N && "Invalid dest range");
- std::copy(Other.first + i, Other.first + i + Count, first + j);
- std::copy(Other.second + i, Other.second + i + Count, second + j);
+ for (unsigned e = i + Count; i != e; ++i, ++j) {
+ first[j] = Other.first[i];
+ second[j] = Other.second[i];
+ }
}
/// moveLeft - Move elements to the left.
@@ -231,8 +232,10 @@ public:
void moveRight(unsigned i, unsigned j, unsigned Count) {
assert(i <= j && "Use moveLeft shift elements left");
assert(j + Count <= N && "Invalid range");
- std::copy_backward(first + i, first + i + Count, first + j + Count);
- std::copy_backward(second + i, second + i + Count, second + j + Count);
+ while (Count--) {
+ first[j + Count] = first[i + Count];
+ second[j + Count] = second[i + Count];
+ }
}
/// erase - Erase elements [i;j).