llvm.org GIT mirror llvm / 08d5534
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 Jakob Stoklund Olesen 9 years ago
1 changed file(s) with 8 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
102102 #include "llvm/ADT/PointerIntPair.h"
103103 #include "llvm/Support/Allocator.h"
104104 #include "llvm/Support/RecyclingAllocator.h"
105 #include
106105 #include
107106
108107 // FIXME: Remove debugging code.
210209 unsigned j, unsigned Count) {
211210 assert(i + Count <= M && "Invalid source range");
212211 assert(j + Count <= N && "Invalid dest range");
213 std::copy(Other.first + i, Other.first + i + Count, first + j);
214 std::copy(Other.second + i, Other.second + i + Count, second + j);
212 for (unsigned e = i + Count; i != e; ++i, ++j) {
213 first[j] = Other.first[i];
214 second[j] = Other.second[i];
215 }
215216 }
216217
217218 /// moveLeft - Move elements to the left.
230231 void moveRight(unsigned i, unsigned j, unsigned Count) {
231232 assert(i <= j && "Use moveLeft shift elements left");
232233 assert(j + Count <= N && "Invalid range");
233 std::copy_backward(first + i, first + i + Count, first + j + Count);
234 std::copy_backward(second + i, second + i + Count, second + j + Count);
234 while (Count--) {
235 first[j + Count] = first[i + Count];
236 second[j + Count] = second[i + Count];
237 }
235238 }
236239
237240 /// erase - Erase elements [i;j).