Ignore:
Timestamp:
Oct 12, 2001, 5:48:06 AM (24 years ago)
Author:
phaller
Message:

heap acceleration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/os2heap.cpp

    r6975 r7027  
    1 /* $Id: os2heap.cpp,v 1.26 2001-10-09 20:25:20 sandervl Exp $ */
     1/* $Id: os2heap.cpp,v 1.27 2001-10-12 03:48:06 phaller Exp $ */
    22
    33/*
     
    4545void   _LNK_CONV releaseHeapMem(Heap_t pHeap, void *block, size_t size);
    4646
     47
     48//******************************************************************************
     49// Fast Heap Handle Management
     50//******************************************************************************
     51
     52static HANDLE   fhhm_lastHandle = 0;
     53static OS2Heap* fhhm_lastHeap   = NULL;
     54
     55
    4756//******************************************************************************
    4857//******************************************************************************
    4958OS2Heap::OS2Heap(DWORD flOptions, DWORD dwInitialSize, DWORD dwMaximumSize)
    5059{
    51  OS2Heap *curheap = OS2Heap::heap;
    52 
     60  OS2Heap *curheap = OS2Heap::heap;
     61 
    5362  totalAlloc   = 0;
    5463  fInitialized = 0;
     
    98107 OS2Heap *curheap = OS2Heap::heap;
    99108 int i;
    100 
     109 
     110  // invalidate handle cache
     111  fhhm_lastHandle = 0;
     112  fhhm_lastHeap   = NULL;
     113 
     114 
    101115  dprintf(("dtr OS2Heap, hPrimaryHeap = %X\n", hPrimaryHeap));
    102116
     
    291305OS2Heap *OS2Heap::find(HANDLE hHeap)
    292306{
     307  // check against cache first
     308  if (fhhm_lastHeap)
     309    if (hHeap == fhhm_lastHandle)
     310      return fhhm_lastHeap;
     311 
    293312  OS2Heap *curheap = OS2Heap::heap;
    294 
     313 
    295314  //@@@PH NT programs seem to assume heap 0 is always valid?!
    296315  if (hHeap == 0)
    297      if (curheap != NULL)
    298        return curheap;
    299 
    300   while(curheap != NULL) {
    301         if(curheap->hPrimaryHeap == hHeap) {
    302                 return(curheap);
    303         }
    304         curheap = curheap->next;
     316    if (curheap != NULL)
     317    {
     318      fhhm_lastHandle = hHeap;
     319      fhhm_lastHeap   = curheap;
     320      return curheap;
     321    }
     322
     323  while(curheap != NULL)
     324  {
     325    if(curheap->hPrimaryHeap == hHeap)
     326    {
     327      fhhm_lastHandle = hHeap;
     328      fhhm_lastHeap   = curheap;
     329      return(curheap);
     330    }
     331    curheap = curheap->next;
    305332  }
    306333  dprintf(("Heap %X not found!\n", hHeap));
     334  fhhm_lastHandle = hHeap;
     335  fhhm_lastHeap   = NULL;
    307336  return(NULL);
    308337}
Note: See TracChangeset for help on using the changeset viewer.