[llvm-commits] CVS: poolalloc/runtime/PoolAllocator/PoolAllocatorBitMask.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Nov 8 21:10:00 PST 2003
Changes in directory poolalloc/runtime/PoolAllocator:
PoolAllocatorBitMask.cpp updated: 1.29 -> 1.30
---
Log message:
containsElement is called a LOT. Speed it up a bit
---
Diffs of the changes: (+10 -10)
Index: poolalloc/runtime/PoolAllocator/PoolAllocatorBitMask.cpp
diff -u poolalloc/runtime/PoolAllocator/PoolAllocatorBitMask.cpp:1.29 poolalloc/runtime/PoolAllocator/PoolAllocatorBitMask.cpp:1.30
--- poolalloc/runtime/PoolAllocator/PoolAllocatorBitMask.cpp:1.29 Sat Nov 8 18:37:16 2003
+++ poolalloc/runtime/PoolAllocator/PoolAllocatorBitMask.cpp Sat Nov 8 21:09:43 2003
@@ -331,16 +331,16 @@
// this slab. If the address is not in slab, return -1.
int PoolSlab::containsElement(void *Ptr, unsigned ElementSize) const {
const void *FirstElement = getElementAddress(0, 0);
- if (FirstElement > Ptr ||
- (char*)getElementAddress(ElementSize, getSlabSize())-1 < Ptr)
- return -1;
-
- unsigned Index = (char*)Ptr-(char*)FirstElement;
- assert(Index % ElementSize == 0 &&
- "Freeing pointer into the middle of an element!");
- Index /= ElementSize;
- assert(Index < getSlabSize() && "Pool slab searching loop broken!");
- return Index;
+ if (FirstElement <= Ptr) {
+ unsigned Index = (char*)Ptr-(char*)FirstElement;
+ Index /= ElementSize;
+ if (Index < getSlabSize()) {
+ assert(Index % ElementSize == 0 &&
+ "Freeing pointer into the middle of an element!");
+ return Index;
+ }
+ }
+ return -1;
}
More information about the llvm-commits
mailing list