Opened 21 years ago
Last modified 18 years ago
#314 closed defect (fixed)
AVC speedup patch - - not so many file stat()s
Reported by: | Owned by: | Daniel Morissette | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | OGR_SF | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: | Markus Neteler |
Description
The included patch speeds up the ogr/orgsf_formats/avc backend format The curent behavior is to try a file stat() on the upper and lower case for each letter of the file path of the coverage. That is a lot of file stat()s. In many cases the entire file is either all lower case (Arc/Info in Solaris) or all upper case. This patch tries these two common cases before trying all the other permutations. It speeds up an AvcReadOpenfile from 98 seconds to 1 second. (Arc/Info Solaris Workspace with 1500 coverages) cut here ------------------------------------------------------ diff -ur gdal/ogr/ogrsf_frmts/avc/avc_misc.c gdal_new/ogr/ogrsf_frmts/avc/avc_misc.c --- gdal/ogr/ogrsf_frmts/avc/avc_misc.c Thu Feb 14 09:37:21 2002 +++ gdal_new/ogr/ogrsf_frmts/avc/avc_misc.c Sat Apr 5 14:27:51 2003 @@ -261,12 +261,45 @@ return pszFname; } + pszTmpPath = CPLStrdup(pszFname); + nTotalLen = strlen(pszTmpPath); + + /*----------------------------------------------------------------- + * Try all lower case, check if the filename is OK as that. + *----------------------------------------------------------------*/ + for (iTmpPtr=0; iTmpPtr< nTotalLen; iTmpPtr++) + { + if ( pszTmpPath[iTmpPtr] >= 0x41 && pszTmpPath[iTmpPtr] <= 0x5a ) + pszTmpPath[iTmpPtr] += 32; + } + + if (VSIStat(pszTmpPath, &sStatBuf) == 0) + { + strcpy(pszFname, pszTmpPath); + CPLFree(pszTmpPath); + return pszFname; + } + + /*----------------------------------------------------------------- + * Try all upper case, check if the filename is OK as that. + *----------------------------------------------------------------*/ + for (iTmpPtr=0; iTmpPtr< nTotalLen; iTmpPtr++) + { + if ( pszTmpPath[iTmpPtr] >= 0x61 && pszTmpPath[iTmpPtr] <= 0x7a ) + pszTmpPath[iTmpPtr] -= 32; + } + + if (VSIStat(pszTmpPath, &sStatBuf) == 0) + { + strcpy(pszFname, pszTmpPath); + CPLFree(pszTmpPath); + return pszFname; + } + /*----------------------------------------------------------------- * OK, file either does not exist or has the wrong cases... we'll * go backwards until we find a portion of the path that is valid. *----------------------------------------------------------------*/ - pszTmpPath = CPLStrdup(pszFname); - nTotalLen = strlen(pszTmpPath); iTmpPtr = nTotalLen; bValidPath = FALSE;
Change History (3)
comment:2 by , 20 years ago
Carl, I had kind of wanted to change look at using code to fetch the files in the directory and do a case insensitive search against those rather than doing all this stat()ing, but I never got the time. I have applied your changes upstream to Daniel's AVCE00 library in CVS. Thanks for the patch!
comment:3 by , 18 years ago
Marking fixed since the patch has been applied a while ago. We will keep reading the directory and doing a case-insensitive search as an enahncement in the AVCE00 bugzilla at http://bugzilla.maptools.org/show_bug.cgi?id=173
Note:
See TracTickets
for help on using tickets.