[RTL] Use LastEntryInSegment to speed up RtlpFindAndCommitPages. CORE-14588

This commit is contained in:
Thomas Faber 2020-02-02 12:54:19 +01:00
parent c4f736e8f4
commit 52f103c85b
No known key found for this signature in database
GPG key ID: 076E7C3D44720826

View file

@ -665,16 +665,21 @@ RtlpFindAndCommitPages(PHEAP Heap,
/* Calculate first and last entries */
FirstEntry = (PHEAP_ENTRY)Address;
/* Go through the entries to find the last one */
if (PreviousUcr)
LastEntry = (PHEAP_ENTRY)((ULONG_PTR)PreviousUcr->Address + PreviousUcr->Size);
else
LastEntry = &Segment->Entry;
while (!(LastEntry->Flags & HEAP_ENTRY_LAST_ENTRY))
LastEntry = Segment->LastEntryInSegment;
if (!(LastEntry->Flags & HEAP_ENTRY_LAST_ENTRY) ||
LastEntry + LastEntry->Size != FirstEntry)
{
ASSERT(LastEntry->Size != 0);
LastEntry += LastEntry->Size;
/* Go through the entries to find the last one */
if (PreviousUcr)
LastEntry = (PHEAP_ENTRY)((ULONG_PTR)PreviousUcr->Address + PreviousUcr->Size);
else
LastEntry = &Segment->Entry;
while (!(LastEntry->Flags & HEAP_ENTRY_LAST_ENTRY))
{
ASSERT(LastEntry->Size != 0);
LastEntry += LastEntry->Size;
}
}
ASSERT((LastEntry + LastEntry->Size) == FirstEntry);