From fd22157e554a3f71eceec83dde1070ce76071e0d Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 30 Apr 2002 12:58:57 -0400 Subject: ENH: improve speed of GetSource function --- Source/cmMakefile.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index db4a7e5..610c294 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1310,11 +1310,19 @@ cmData* cmMakefile::LookupData(const char* name) const cmSourceFile* cmMakefile::GetSource(const char* sourceName) { + std::string s = sourceName; + std::string ext; + std::string::size_type pos = s.rfind('.'); + if(pos != std::string::npos) + { + ext = s.substr(pos+1, s.size() - pos-1); + s = s.substr(0, pos); + } for(std::vector::iterator i = m_SourceFiles.begin(); i != m_SourceFiles.end(); ++i) { - if((*i)->GetSourceName() == sourceName - || (*i)->GetSourceName()+"."+(*i)->GetSourceExtension() == sourceName) + if((*i)->GetSourceName() == s + && (ext.size() == 0 || (ext == (*i)->GetSourceExtension()))) { return *i; } -- cgit v0.12