Commit c508e707 by Mohan Maiya Committed by Commit Bot

Vulkan: Avoid using assign with BitSets

FastIntegerSet::clear() now calls reset() instead of assign(). std::vector::assign(...) invokes the copy-constructor. For better performance, especially with BitSet*, we can leverage the reset() method. This removes 1.2% CPU overhead from a Manhattan30 offscreen run Bug: angleproject:5689 Change-Id: Ib1a760587ffe18341b8ed892a732c506fc50c82b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2723494 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent 2b55f876
...@@ -561,11 +561,17 @@ class FastIntegerSet final ...@@ -561,11 +561,17 @@ class FastIntegerSet final
return (sizedKey < capacity()) && (mKeyData[index].test(offset)); return (sizedKey < capacity()) && (mKeyData[index].test(offset));
} }
ANGLE_INLINE void clear() { mKeyData.assign(mKeyData.capacity(), KeyBitSet::Zero()); } ANGLE_INLINE void clear()
{
for (KeyBitSet &it : mKeyData)
{
it.reset();
}
}
ANGLE_INLINE bool empty() const ANGLE_INLINE bool empty() const
{ {
for (KeyBitSet it : mKeyData) for (const KeyBitSet &it : mKeyData)
{ {
if (it.any()) if (it.any())
{ {
...@@ -578,7 +584,7 @@ class FastIntegerSet final ...@@ -578,7 +584,7 @@ class FastIntegerSet final
ANGLE_INLINE size_t size() const ANGLE_INLINE size_t size() const
{ {
size_t valid_entries = 0; size_t valid_entries = 0;
for (KeyBitSet it : mKeyData) for (const KeyBitSet &it : mKeyData)
{ {
valid_entries += it.count(); valid_entries += it.count();
} }
......
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