diff options
author | Kostya Serebryany <kcc@google.com> | 2016-08-03 03:42:55 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2016-08-03 03:42:55 +0000 |
commit | 2b59210e9efb483860658b0a85e8502f2f883231 (patch) | |
tree | 059e21c03f70e189a85cc63ff4733f8ae5d13b29 /lib/sanitizer_common/sanitizer_allocator_local_cache.h | |
parent | 35b5cec19b359abba312448fd32fa0cb229ce92e (diff) |
[sanitizer] remove one redundant loop from the allocator
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277563 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_allocator_local_cache.h')
-rw-r--r-- | lib/sanitizer_common/sanitizer_allocator_local_cache.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/sanitizer_common/sanitizer_allocator_local_cache.h b/lib/sanitizer_common/sanitizer_allocator_local_cache.h index 780c45c0c..4fe99561f 100644 --- a/lib/sanitizer_common/sanitizer_allocator_local_cache.h +++ b/lib/sanitizer_common/sanitizer_allocator_local_cache.h @@ -119,12 +119,11 @@ struct SizeClassAllocatorLocalCache { NOINLINE void Drain(SizeClassAllocator *allocator, uptr class_id) { InitCache(); PerClass *c = &per_class_[class_id]; - Batch *b = CreateBatch(class_id, allocator, (Batch*)c->batch[0]); uptr cnt = Min(c->max_count / 2, c->count); - b->SetFromArray(c->batch, cnt); - for (uptr i = 0; i < cnt; i++) - c->batch[i] = c->batch[i + c->max_count / 2]; - + uptr first_idx_to_drain = c->count - cnt; + Batch *b = + CreateBatch(class_id, allocator, (Batch *)c->batch[first_idx_to_drain]); + b->SetFromArray(&c->batch[first_idx_to_drain], cnt); c->count -= cnt; allocator->DeallocateBatch(&stats_, class_id, b); } |