optimize GetExtension

This commit is contained in:
Glenn Maynard
2003-10-22 05:49:26 +00:00
parent da14c54268
commit 2715b39ba3
+9 -4
View File
@@ -317,10 +317,15 @@ CString SetExtension( const CString &path, const CString &ext )
CString GetExtension( CString sPath )
{
CString Dir, FName, Ext;
splitrelpath( sPath, Dir, FName, Ext );
Ext.MakeLower();
return Ext;
unsigned pos = sPath.rfind( '.' );
if( pos == sPath.npos )
return "";
unsigned slash = sPath.find( '/', slash );
if( slash != sPath.npos )
return ""; /* rare: path/dir.ext/fn */
return sPath.substr( pos+1, sPath.size()-pos+1 );
}
CString GetCwd()