From 2715b39ba3adf7072092ee4d73647e71d34addba Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 22 Oct 2003 05:49:26 +0000 Subject: [PATCH] optimize GetExtension --- stepmania/src/RageUtil.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index 8579c72bad..0df150c24f 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -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()