Skip to content

Commit 2aef605

Browse files
committed
[NFC][sanitizer] Micro optimize push_back()
1 parent 53be2e0 commit 2aef605

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,8 @@ class InternalMmapVectorNoCtor {
519519
return data_[i];
520520
}
521521
void push_back(const T &element) {
522-
CHECK_LE(size_, capacity());
523-
if (size_ == capacity()) {
522+
if (UNLIKELY(size_ >= capacity())) {
523+
CHECK_EQ(size_, capacity());
524524
uptr new_capacity = RoundUpToPowerOfTwo(size_ + 1);
525525
Realloc(new_capacity);
526526
}
@@ -580,7 +580,7 @@ class InternalMmapVectorNoCtor {
580580
}
581581

582582
private:
583-
void Realloc(uptr new_capacity) {
583+
NOINLINE void Realloc(uptr new_capacity) {
584584
CHECK_GT(new_capacity, 0);
585585
CHECK_LE(size_, new_capacity);
586586
uptr new_capacity_bytes =

0 commit comments

Comments
 (0)