Ignore:
Timestamp:
May 28, 2001, 1:26:50 PM (24 years ago)
Author:
phaller
Message:

Slightly accelerated ::findMapByView

File:
1 edited

Legend:

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

    r5027 r5815  
    1 /* $Id: mmap.cpp,v 1.50 2001-01-25 20:18:05 sandervl Exp $ */
     1/* $Id: mmap.cpp,v 1.51 2001-05-28 11:26:06 phaller Exp $ */
    22
    33/*
     
    709709//******************************************************************************
    710710//******************************************************************************
    711 Win32MemMap *Win32MemMapView::findMapByView(ULONG address, ULONG *offset,
     711Win32MemMap *Win32MemMapView::findMapByView(ULONG address,
     712                                            ULONG *offset,
    712713                                            ULONG accessType,
    713714                                            Win32MemMapView **pView)
     
    715716  globalviewMutex.enter();
    716717  Win32MemMapView *view = mapviews;
     718  ULONG ulViewAddr;
    717719
    718720  *offset = 0;
    719721
    720   if(view != NULL) {
    721     while(view && (ULONG)view->getViewAddr() <= address) {
    722         if((ULONG)view->getViewAddr() <= address &&
    723                    (ULONG)view->getViewAddr() + view->getSize() > address &&
    724                    view->getAccessFlags() >= accessType)
     722  if(view != NULL)
     723  {
     724    do
     725    {
     726      ulViewAddr = (ULONG)view->getViewAddr();
     727
     728      // if ulViewAddr is > address, we've exhausted
     729      // the sorted list already and can abort search.
     730      if(ulViewAddr <= address)
     731      {
     732        if(ulViewAddr + view->getSize() > address &&
     733           view->getAccessFlags() >= accessType)
    725734        {
    726             *offset = view->getOffset() + (address - (ULONG)view->getViewAddr());
    727             goto success;
    728         }
     735          *offset = view->getOffset() + (address - ulViewAddr);
     736          goto success;
     737        }
     738
     739        // Not found yet, continue search with next map
    729740        view = view->next;
    730     }
     741      }
     742      else
     743      {
     744          // list is exhausted, abort loop
     745          view = NULL;
     746      }
     747    }
     748    while(view);
     749 
    731750    //failure if we get here
    732751    view = NULL;
    733752  }
     753
    734754success:
     755#ifdef DEBUG
    735756  if(view && !view->getParentMap()->isImageMap())
    736     dprintf(("findMapByView %x %x -> %x off %x", address, accessType, view->getViewAddr(), *offset));
     757      dprintf(("findMapByView %x %x -> %x off %x",
     758               address,
     759               accessType,
     760               view->getViewAddr(),
     761               *offset));
     762#endif
    737763
    738764  globalviewMutex.leave();
    739   if(pView) *pView = view;
     765
     766  if(pView)
     767      *pView = view;
     768
    740769  return (view) ? view->getParentMap() : NULL;
    741770}
Note: See TracChangeset for help on using the changeset viewer.