Changeset 9146


Ignore:
Timestamp:
Aug 28, 2002, 4:12:55 AM (23 years ago)
Author:
bird
Message:

Use binary search on the dependency history. (saves another 20-30 on linux headers.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/fastdep/fastdep.c

    r9145 r9146  
    1 /* $Id: fastdep.c,v 1.40 2002-08-27 21:48:45 bird Exp $
     1/* $Id: fastdep.c,v 1.41 2002-08-28 02:12:55 bird Exp $
    22 *
    33 * Fast dependents. (Fast = Quick and Dirty!)
     
    37813781    int     iHistory;
    37823782    int     j;
    3783     int     k;
     3783    int     iStart;
     3784    int     iEnd;
    37843785    int     iCmp;
    37853786#endif
     
    38273828                 * Check if in history, if so we'll skip it.
    38283829                 */
    3829                 #if 1
     3830                #if 0
    38303831                for (j = 0;  j < iHistory; j++)
    38313832                    if (!strcmp(apszHistory[j], pdep->pszRule))
    38323833                        break;
    38333834                if (j != iHistory)
    3834                     continue;
     3835                    continue;           /* found */
    38353836
    38363837                /*
     
    38413842
    38423843                #else
     3844
    38433845                /*
    38443846                 * Check if in history, if so we'll skip it.
     
    38463848                 * ASSUMES: Always something in the history!
    38473849                 */
     3850                iEnd = iHistory - 1;
     3851                iStart = 0;
    38483852                j = iHistory / 2;
    3849                 k = (iHistory + 1) / 2;
    3850                 do
     3853                while (    (iCmp = strcmp(pdep->pszRule, apszHistory[j])) != 0
     3854                       &&   iEnd != iStart)
    38513855                {
    3852                     iCmp = strcmp(pdep->pszRule, apszHistroy[j]);
    3853                     if (!iCmp)
     3856                    if (iCmp < 0)
     3857                        iEnd = j - 1;
     3858                    else
     3859                        iStart = j + 1;
     3860                    if (iStart > iEnd)
    38543861                        break;
    3855                     k = (k + 1) / 2;
    3856                     if (iCmp > 0)
    3857                         j += k;
    3858                     else
    3859                         j -= k;
    3860                 } while (!k);
    3861 
    3862                 if (!iCmp)
     3862                    j = (iStart + iEnd) / 2;
     3863                }
     3864
     3865                if (!iCmp)
    38633866                    continue;           /* found */
    38643867
     
    38683871                if (iHistory < HISTORY)
    38693872                {
     3873                    int k;
    38703874                    if (iCmp > 0)       /* Insert after. */
    38713875                        j++;
    3872                     for (k = iHistory; k < j; k--)
     3876                    for (k = iHistory; k > j; k--)
    38733877                        apszHistory[k] = apszHistory[k - 1];
    38743878                    apszHistory[j] = pdep->pszRule;
Note: See TracChangeset for help on using the changeset viewer.