Changeset 13600
- Timestamp:
- 01/26/08 11:23:05 (4 months ago)
- Files:
-
- trunk/gdal/port/cpl_string.cpp (modified) (1 diff)
- trunk/gdal/port/cpl_vsil_unix_stdio_64.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gdal/port/cpl_string.cpp
r13540 r13600 67 67 * StringList. 68 68 * If the input StringList is NULL, then a new StringList is created. 69 * Note that CSLAddString performance when building a list is in O(n^2) 70 * which can cause noticable slow down when n > 10000. 69 71 **********************************************************************/ 70 72 char **CSLAddString(char **papszStrList, const char *pszNewString) trunk/gdal/port/cpl_vsil_unix_stdio_64.cpp
r13594 r13600 356 356 if ( (hDir = opendir(pszPath)) != NULL ) 357 357 { 358 /* In case of really big number of files in the directory, CSLAddString */ 359 /* can be slow (see #2158). We then directly build the list. */ 360 int nItems=0; 361 int nAllocatedItems=0; 358 362 while( (psDirEntry = readdir(hDir)) != NULL ) 359 363 { 360 papszDir = CSLAddString(papszDir, psDirEntry->d_name); 364 if (nItems == 0) 365 { 366 papszDir = (char**) CPLCalloc(2,sizeof(char*)); 367 nAllocatedItems = 1; 368 } 369 else if (nItems >= nAllocatedItems) 370 { 371 nAllocatedItems = nAllocatedItems * 2; 372 papszDir = (char**)CPLRealloc(papszDir, 373 (nAllocatedItems+2)*sizeof(char*)); 374 } 375 376 papszDir[nItems] = CPLStrdup(psDirEntry->d_name); 377 papszDir[nItems+1] = NULL; 378 379 nItems++; 361 380 } 362 381
