ソースを参照

ENH: improve speed of GetSource function

Bill Hoffman 23 年 前
コミット
fd22157e55
1 ファイル変更10 行追加2 行削除
  1. 10 2
      Source/cmMakefile.cxx

+ 10 - 2
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<cmSourceFile*>::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;
       }