Changeset 3169 for trunk/tools


Ignore:
Timestamp:
Mar 19, 2000, 5:23:55 PM (26 years ago)
Author:
bird
Message:

Optimize use of strlwr. Use fopen(.., "rb") to speed up reads.

File:
1 edited

Legend:

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

    r3162 r3169  
    1 /* $Id: fastdep.c,v 1.15 2000-03-18 23:56:24 bird Exp $
     1/* $Id: fastdep.c,v 1.16 2000-03-19 16:23:55 bird Exp $
    22 *
    33 * Fast dependents. (Fast = Quick and Dirty!)
     
    230230
    231231/*
     232 * Environment variables used.
     233 * (These has the correct case.)
     234 */
     235static char *   pszIncludeEnv;
     236
     237
     238/*
    232239 * Configuration stuff.
    233240 */
     
    292299    int         argi = 1;
    293300    int         i;
     301    char *      psz;
    294302    const char *pszDepFile = pszDefaultDepFile;
    295303    char        achBuffer[4096];
     
    349357        szCurDir[i] = '\0';
    350358    }
     359
     360
     361    /*
     362     * Initiate environment variables used: INCLUDE
     363     */
     364    psz = getenv("INCLUDE");
     365    if (psz != NULL)
     366    {
     367        pszIncludeEnv = strdup(psz);
     368        strlwr(pszIncludeEnv);
     369    }
     370    else
     371        pszIncludeEnv = "";
     372
    351373
    352374    /*
     
    416438                        argi++;
    417439                    }
     440                    strlwr(szExclude);
    418441                    if (szExclude[strlen(szExclude)-1] != ';')
    419442                        strcat(szExclude, ";");
     
    429452                        argi++;
    430453                    }
     454                    strlwr(szInclude);
    431455                    if (szInclude[strlen(szInclude)-1] != ';')
    432456                        strcat(szInclude, ";");
     
    608632                        szSource[0]  = '\0';
    609633                    strcat(szSource, pfindbuf3->achName);
     634                    strlwr(szSource);
    610635
    611636                    /*
     
    687712 * and written to file later.
    688713 * @returns
    689  * @param     pszFilename  Pointer to source filename.
     714 * @param     pszFilename  Pointer to source filename. Correct case is assumed!
    690715 * @param     pOptions     Pointer to options struct.
    691716 * @status    completely implemented.
     
    745770 * @returns   0 on success.
    746771 *            !0 on error.
    747  * @param     pszFilename  Pointer to source filename.
     772 * @param     pszFilename  Pointer to source filename. Correct case is assumed!
    748773 * @param     pvFile       Pointer to file textbuffer.
    749774 * @param     pOptions     Pointer to options struct.
     
    885910                    strncpy(szFullname, &szBuffer[i], j);
    886911                    szFullname[j] = '\0'; /* ensure terminatition. */
     912                    strlwr(szFullname);
    887913
    888914                    /* find include file! */
    889915                    psz = pathlistFindFile(pOptions->pszInclude, szFullname, szBuffer, pOptions);
    890916                    if (psz == NULL)
    891                         psz = pathlistFindFile(getenv("INCLUDE"), szFullname, szBuffer, pOptions);
     917                        psz = pathlistFindFile(pszIncludeEnv, szFullname, szBuffer, pOptions);
    892918
    893919                    /* did we find the include? */
     
    10241050 * @returns   0 on success.
    10251051 *            !0 on error.
    1026  * @param     pszFilename  Pointer to source filename.
     1052 * @param     pszFilename  Pointer to source filename. Correct case is assumed!
    10271053 * @param     pvFile       Pointer to file textbuffer.
    10281054 * @param     pOptions     Pointer to options struct.
     
    11101136            strncpy(szFullname, &szBuffer[i], j);
    11111137            szFullname[j] = '\0'; /* ensure terminatition. */
     1138            strlwr(szFullname);
    11121139
    11131140            /* find include file! */
    11141141            psz = pathlistFindFile(pOptions->pszInclude, szFullname, szBuffer, pOptions);
    11151142            if (psz == NULL)
    1116                 psz = pathlistFindFile(getenv("INCLUDE"), szFullname, szBuffer, pOptions);
     1143                psz = pathlistFindFile(pszIncludeEnv, szFullname, szBuffer, pOptions);
    11171144
    11181145            /* Did we find the include? */
     
    11421169 * @returns   0 on success.
    11431170 *            !0 on error.
    1144  * @param     pszFilename  Pointer to source filename.
     1171 * @param     pszFilename  Pointer to source filename. Correct case is assumed!
    11451172 * @param     pvFile       Pointer to file textbuffer.
    11461173 * @param     pOptions     Pointer to options struct.
     
    12301257            strncpy(szFullname, &szBuffer[i], j);
    12311258            szFullname[j] = '\0'; /* ensure terminatition. */
     1259            strlwr(szFullname);
    12321260
    12331261            /* find include file! */
    12341262            psz = pathlistFindFile(pOptions->pszInclude, szFullname, szBuffer, pOptions);
    12351263            if (psz == NULL)
    1236                 psz = pathlistFindFile(getenv("INCLUDE"), szFullname, szBuffer, pOptions);
     1264                psz = pathlistFindFile(pszIncludeEnv, szFullname, szBuffer, pOptions);
    12371265
    12381266            /* did we find the include? */
     
    12621290 * @returns   0 on success.
    12631291 *            !0 on error.
    1264  * @param     pszFilename  Pointer to source filename.
     1292 * @param     pszFilename  Pointer to source filename. Correct case is assumed!
    12651293 * @param     pvFile       Pointer to file textbuffer.
    12661294 * @param     pOptions     Pointer to options struct.
     
    13791407            strncpy(szFullname, &szBuffer[i], j);
    13801408            szFullname[j] = '\0'; /* ensure terminatition. */
     1409            strlwr(szFullname);
    13811410
    13821411            /* add extention .cpy - hardcoded for the moment. */
     
    15431572
    15441573    /* lower case it */
    1545     strlwr(psz);
     1574    /*strlwr(psz);*/
    15461575
    15471576    return psz;
     
    17621791    /* Make path */
    17631792    filePathSlash2(pszDir, szDir);
    1764     strlwr(szDir); /* Convert name to lower case to allow faster searchs! */
     1793    //strlwr(szDir); /* Convert name to lower case to allow faster searchs! */
    17651794    cchDir = strlen(szDir);
    17661795
     
    18851914                strcpy(&pszBuffer[pszNext - psz], "\\");
    18861915            strcat(pszBuffer, pszFilename);
    1887             strlwr(pszBuffer); /* to speed up AVL tree search we'll lowercase all names. */
     1916            //strlwr(pszBuffer); /* to speed up AVL tree search we'll lowercase all names. */
    18881917            fileNormalize(pszBuffer);
    18891918
     
    20582087    FILE *phFile;
    20592088
    2060     phFile = fopen(pszFilename, "r");
     2089    phFile = fopen(pszFilename, "rb");
    20612090    if (phFile != NULL)
    20622091    {
     
    21142143
    21152144    /* skip line end */
     2145    if (ch == '\r')
     2146        ch = *++psz;
    21162147    if (ch == '\n')
    2117         psz++;
    2118     if (*psz == '\r')
    21192148        psz++;
    21202149
     
    21552184
    21562185    /* skip line end */
     2186    if (ch == '\r')
     2187        ch = *++psz;
    21572188    if (ch == '\n')
    2158         ch = *++psz;
    2159     if (ch == '\r')
    21602189        psz++;
    21612190
Note: See TracChangeset for help on using the changeset viewer.