Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1423)

Unified Diff: Source/wtf/Vector.h

Issue 23775006: Remove redundant branches and add a little LIKELY / UNLIKELY. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/Vector.h
diff --git a/Source/wtf/Vector.h b/Source/wtf/Vector.h
index 1a5df09ac2bb753f62766c4281b3c46f67b5d01b..4eefbcb3d09419dc98143a5afd1c9bff06b36be6 100644
--- a/Source/wtf/Vector.h
+++ b/Source/wtf/Vector.h
@@ -404,7 +404,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
void deallocateBuffer(T* bufferToDeallocate)
{
- if (bufferToDeallocate == inlineBuffer())
+ if (LIKELY(bufferToDeallocate == inlineBuffer()))
return;
Base::deallocateBuffer(bufferToDeallocate);
}
@@ -491,8 +491,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
: Base(size)
{
m_size = size;
- if (begin())
- TypeOperations::initialize(begin(), end());
+ TypeOperations::initialize(begin(), end());
}
~Vector()
@@ -591,8 +590,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
: Base(size)
{
m_size = size;
- if (begin())
- TypeOperations::uninitializedFill(begin(), end(), val);
+ TypeOperations::uninitializedFill(begin(), end(), val);
}
void fill(const T&, size_t);
@@ -630,8 +628,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
: Base(other.capacity())
{
m_size = other.size();
- if (begin())
- TypeOperations::uninitializedCopy(other.begin(), other.end(), begin());
+ TypeOperations::uninitializedCopy(other.begin(), other.end(), begin());
}
template<typename T, size_t inlineCapacity>
@@ -640,14 +637,13 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
: Base(other.capacity())
{
m_size = other.size();
- if (begin())
- TypeOperations::uninitializedCopy(other.begin(), other.end(), begin());
+ TypeOperations::uninitializedCopy(other.begin(), other.end(), begin());
}
template<typename T, size_t inlineCapacity>
Vector<T, inlineCapacity>& Vector<T, inlineCapacity>::operator=(const Vector<T, inlineCapacity>& other)
{
- if (&other == this)
+ if (UNLIKELY(&other == this))
return *this;
if (size() > other.size())
@@ -812,8 +808,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
else {
if (size > capacity())
expandCapacity(size);
- if (begin())
- TypeOperations::initialize(end(), begin() + size);
+ TypeOperations::initialize(end(), begin() + size);
}
m_size = size;
@@ -833,8 +828,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
ASSERT(size >= m_size);
if (size > capacity())
expandCapacity(size);
- if (begin())
- TypeOperations::initialize(end(), begin() + size);
+ TypeOperations::initialize(end(), begin() + size);
m_size = size;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698