Changeset 14788

Show
Ignore:
Timestamp:
06/30/08 15:08:40 (5 months ago)
Author:
rouault
Message:

Small optimizations in cpl_minixml.cpp

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/port/cpl_minixml.cpp

    r14785 r14788  
    8989/************************************************************************/ 
    9090 
    91 static char ReadChar( ParseContext *psContext ) 
     91static CPL_INLINE char ReadChar( ParseContext *psContext ) 
    9292 
    9393{ 
     
    108108/************************************************************************/ 
    109109 
    110 static void UnreadChar( ParseContext *psContext, char chToUnread ) 
     110static CPL_INLINE void UnreadChar( ParseContext *psContext, char chToUnread ) 
    111111 
    112112{ 
     
    131131/************************************************************************/ 
    132132 
    133 static void AddToToken( ParseContext *psContext, char chNewChar ) 
     133static CPL_INLINE void AddToToken( ParseContext *psContext, char chNewChar ) 
    134134 
    135135{ 
     
    11731173 
    11741174{ 
     1175    char        *apszTokens[2]; 
    11751176    char        **papszTokens; 
    11761177    int         iToken = 0; 
     
    11861187    } 
    11871188 
    1188     papszTokens = CSLTokenizeStringComplex( pszPath, ".", FALSE, FALSE ); 
     1189    /* Slight optimization : avoid using CSLTokenizeStringComplex that */ 
     1190    /* does memory allocations when it is not really necessary */ 
     1191    if (strchr(pszPath, '.')) 
     1192        papszTokens = CSLTokenizeStringComplex( pszPath, ".", FALSE, FALSE ); 
     1193    else 
     1194    { 
     1195        apszTokens[0] = (char*) pszPath; 
     1196        apszTokens[1] = NULL; 
     1197        papszTokens = apszTokens; 
     1198    } 
    11891199 
    11901200    while( papszTokens[iToken] != NULL && psRoot != NULL ) 
     
    12171227    } 
    12181228 
    1219     CSLDestroy( papszTokens ); 
     1229    if (papszTokens != apszTokens) 
     1230        CSLDestroy( papszTokens ); 
    12201231    return psRoot; 
    12211232} 
  • trunk/gdal/port/cpl_port.h

    r14473 r14788  
    234234#else 
    235235#  define FORCE_CDECL  
     236#endif 
     237 
     238/* TODO : support for other compilers needed */ 
     239#if defined(__GNUC__) 
     240#define CPL_INLINE inline 
    236241#endif 
    237242