Changeset 9145 for trunk/tools


Ignore:
Timestamp:
Aug 27, 2002, 11:48:45 PM (23 years ago)
Author:
bird
Message:

going home, taking code with me.

File:
1 edited

Legend:

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

    r9070 r9145  
    1 /* $Id: fastdep.c,v 1.39 2002-08-21 01:51:56 bird Exp $
     1/* $Id: fastdep.c,v 1.40 2002-08-27 21:48:45 bird Exp $
    22 *
    33 * Fast dependents. (Fast = Quick and Dirty!)
     
    37813781    int     iHistory;
    37823782    int     j;
     3783    int     k;
     3784    int     iCmp;
    37833785#endif
    37843786    PDEPRULE pdep;
     
    38253827                 * Check if in history, if so we'll skip it.
    38263828                 */
     3829                #if 1
    38273830                for (j = 0;  j < iHistory; j++)
    38283831                    if (!strcmp(apszHistory[j], pdep->pszRule))
     
    38363839                if (iHistory < HISTORY)
    38373840                    apszHistory[iHistory++] = pdep->pszRule;
     3841
     3842                #else
     3843                /*
     3844                 * Check if in history, if so we'll skip it.
     3845                 *  (Binary search)
     3846                 * ASSUMES: Always something in the history!
     3847                 */
     3848                j = iHistory / 2;
     3849                k = (iHistory + 1) / 2;
     3850                do
     3851                {
     3852                    iCmp = strcmp(pdep->pszRule, apszHistroy[j]);
     3853                    if (!iCmp)
     3854                        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)
     3863                    continue;           /* found */
     3864
     3865                /*
     3866                 * Push into history - might concider make this binary sorted one day.
     3867                 */
     3868                if (iHistory < HISTORY)
     3869                {
     3870                    if (iCmp > 0)       /* Insert after. */
     3871                        j++;
     3872                    for (k = iHistory; k < j; k--)
     3873                        apszHistory[k] = apszHistory[k - 1];
     3874                    apszHistory[j] = pdep->pszRule;
     3875                    iHistory++;
     3876                }
     3877
     3878                #endif
     3879
    38383880#endif
    38393881                /*
Note: See TracChangeset for help on using the changeset viewer.