Skip to content

Commit 52f103c

Browse files
committed
[RTL] Use LastEntryInSegment to speed up RtlpFindAndCommitPages. CORE-14588
1 parent c4f736e commit 52f103c

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

sdk/lib/rtl/heap.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -665,16 +665,21 @@ RtlpFindAndCommitPages(PHEAP Heap,
665665
/* Calculate first and last entries */
666666
FirstEntry = (PHEAP_ENTRY)Address;
667667

668-
/* Go through the entries to find the last one */
669-
if (PreviousUcr)
670-
LastEntry = (PHEAP_ENTRY)((ULONG_PTR)PreviousUcr->Address + PreviousUcr->Size);
671-
else
672-
LastEntry = &Segment->Entry;
673-
674-
while (!(LastEntry->Flags & HEAP_ENTRY_LAST_ENTRY))
668+
LastEntry = Segment->LastEntryInSegment;
669+
if (!(LastEntry->Flags & HEAP_ENTRY_LAST_ENTRY) ||
670+
LastEntry + LastEntry->Size != FirstEntry)
675671
{
676-
ASSERT(LastEntry->Size != 0);
677-
LastEntry += LastEntry->Size;
672+
/* Go through the entries to find the last one */
673+
if (PreviousUcr)
674+
LastEntry = (PHEAP_ENTRY)((ULONG_PTR)PreviousUcr->Address + PreviousUcr->Size);
675+
else
676+
LastEntry = &Segment->Entry;
677+
678+
while (!(LastEntry->Flags & HEAP_ENTRY_LAST_ENTRY))
679+
{
680+
ASSERT(LastEntry->Size != 0);
681+
LastEntry += LastEntry->Size;
682+
}
678683
}
679684
ASSERT((LastEntry + LastEntry->Size) == FirstEntry);
680685

0 commit comments

Comments
 (0)