From 1d5314162fa6eb75328c6c3609e4920e392d9bf1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Sat, 8 Feb 2014 03:45:06 -0500 Subject: [PATCH] Glob: Accept a string in Glob::AddFile If Relative was non-empty, the parameter is unconditionally casted into a string anyways, so save the allocation. Change-Id: I835782fa0307c0122cacf032d4937b5646561d7f --- Glob.cxx | 8 ++++---- Glob.hxx.in | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Glob.cxx b/Glob.cxx index 6ac6b97..ef35a40 100644 --- a/Glob.cxx +++ b/Glob.cxx @@ -273,7 +273,7 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start, if ( !this->Internals->Expressions.empty() && this->Internals->Expressions.rbegin()->find(fname) ) { - this->AddFile(this->Internals->Files, realname.c_str()); + this->AddFile(this->Internals->Files, realname); } } } @@ -351,7 +351,7 @@ void Glob::ProcessDirectory(kwsys_stl::string::size_type start, { if ( last ) { - this->AddFile(this->Internals->Files, realname.c_str()); + this->AddFile(this->Internals->Files, realname); } else { @@ -497,11 +497,11 @@ const char* Glob::GetRelative() } //---------------------------------------------------------------------------- -void Glob::AddFile(kwsys_stl::vector<kwsys_stl::string>& files, const char* file) +void Glob::AddFile(kwsys_stl::vector<kwsys_stl::string>& files, const kwsys_stl::string& file) { if ( !this->Relative.empty() ) { - files.push_back(kwsys::SystemTools::RelativePath(this->Relative.c_str(), file)); + files.push_back(kwsys::SystemTools::RelativePath(this->Relative.c_str(), file.c_str())); } else { diff --git a/Glob.hxx.in b/Glob.hxx.in index 88c343c..806c680 100644 --- a/Glob.hxx.in +++ b/Glob.hxx.in @@ -94,7 +94,7 @@ protected: void AddExpression(const char* expr); //! Add a file to the list - void AddFile(kwsys_stl::vector<kwsys_stl::string>& files, const char* file); + void AddFile(kwsys_stl::vector<kwsys_stl::string>& files, const kwsys_stl::string& file); GlobInternals* Internals; bool Recurse; -- GitLab