Simplify VectorMover<true, T>::swap()

Simplify VectorMover<true, T>::swap() - use std::swap_ranges instead
of creating the loop ourselves, plus the patch removes a "FIXME"
comment - compiler already produces the most efficient code for POD
types swap, so there is no need to introduce compex algorithms for
that (checked with GCC 4.7.2).

Review URL: https://codereview.chromium.org/208253003

git-svn-id: svn://svn.chromium.org/blink/trunk@169747 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e1e59fb0
...@@ -160,14 +160,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE; ...@@ -160,14 +160,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
} }
static void swap(T* src, T* srcEnd, T* dst) static void swap(T* src, T* srcEnd, T* dst)
{ {
char* srcC = reinterpret_cast<char*>(src); std::swap_ranges(reinterpret_cast<char*>(src), reinterpret_cast<char*>(srcEnd), reinterpret_cast<char*>(dst));
char* srcEndC = reinterpret_cast<char*>(srcEnd);
char* dstC = reinterpret_cast<char*>(dst);
// FIXME: Below performs per-byte swap. This can be optimized by doing coarce-grained swap before-hand.
size_t size = srcEndC - srcC;
for (size_t i = 0; i < size; ++i)
std::swap(srcC[i], dstC[i]);
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment