From 10baf00f3d14124ee97ca12510595501d66ed70e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 8 Feb 2014 21:35:52 -0500 Subject: [PATCH] cmSourceFile: Cache the isUiFile check The filename extension call is expensive, so cache the .ui check. --- Source/cmSourceFile.cxx | 6 +++--- Source/cmSourceFile.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 0ab30a2c7..3b130ec61 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -24,6 +24,8 @@ cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name): this->CustomCommand = 0; this->Properties.SetCMakeInstance(mf->GetCMakeInstance()); this->FindFullPathFailed = false; + this->IsUiFile = ("ui" == + cmSystemTools::GetFilenameLastExtension(this->Location.GetName())); } //---------------------------------------------------------------------------- @@ -297,9 +299,7 @@ void cmSourceFile::SetProperty(const std::string& prop, const char* value) { this->Properties.SetProperty(prop, value, cmProperty::SOURCE_FILE); - std::string ext = - cmSystemTools::GetFilenameLastExtension(this->Location.GetName()); - if (ext == ".ui") + if (this->IsUiFile) { cmMakefile const* mf = this->Location.GetMakefile(); if (prop == "AUTOUIC_OPTIONS") diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index a1d9de1c0..42d6f8af2 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -109,6 +109,7 @@ private: std::string FullPath; bool FindFullPathFailed; std::string ObjectLibrary; + bool IsUiFile; bool FindFullPath(std::string* error); bool TryFullPath(const std::string& path, const std::string& ext);