Skip to content

Commit cab44f5

Browse files
author
Rishabh Kabra
committed
Check during truncate if memory block belongs to current thread, in which case it can be assigned to the binned list directly instead of the unbinned list.
1 parent 101b79a commit cab44f5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

allocator.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,11 @@ static inline void truncateMemoryBlock (MemoryBlock * mb, size_t new_size) {
337337
nextBlock->isFree = true;
338338
nextBlock->threadInfo = mb->threadInfo;
339339
assignBlockFooter(nextBlock);
340-
assignBlockToThreadSpecificUnbinnedList(nextBlock);
340+
if (nextBlock->threadInfo == &currentThreadInfo) {
341+
assignBlockToBinnedList(nextBlock);
342+
} else {
343+
assignBlockToThreadSpecificUnbinnedList(nextBlock);
344+
}
341345
mb->size = new_size;
342346
assignBlockFooter(mb);
343347
}

0 commit comments

Comments
 (0)