mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-01 20:28:37 -06:00
Avoid some copies
This commit is contained in:
@@ -247,7 +247,10 @@ public:
|
|||||||
|
|
||||||
void StopWatching() final {}
|
void StopWatching() final {}
|
||||||
|
|
||||||
void AppendCallback(cmFileMonitor::Callback cb) { CbList.push_back(cb); }
|
void AppendCallback(cmFileMonitor::Callback const& cb)
|
||||||
|
{
|
||||||
|
this->CbList.push_back(cb);
|
||||||
|
}
|
||||||
|
|
||||||
std::string Path() const final
|
std::string Path() const final
|
||||||
{
|
{
|
||||||
@@ -310,7 +313,7 @@ cmFileMonitor::~cmFileMonitor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmFileMonitor::MonitorPaths(const std::vector<std::string>& paths,
|
void cmFileMonitor::MonitorPaths(const std::vector<std::string>& paths,
|
||||||
Callback cb)
|
Callback const& cb)
|
||||||
{
|
{
|
||||||
for (const auto& p : paths) {
|
for (const auto& p : paths) {
|
||||||
std::vector<std::string> pathSegments;
|
std::vector<std::string> pathSegments;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public:
|
|||||||
~cmFileMonitor();
|
~cmFileMonitor();
|
||||||
|
|
||||||
using Callback = std::function<void(const std::string&, int, int)>;
|
using Callback = std::function<void(const std::string&, int, int)>;
|
||||||
void MonitorPaths(const std::vector<std::string>& paths, Callback cb);
|
void MonitorPaths(const std::vector<std::string>& paths, Callback const& cb);
|
||||||
void StopMonitoring();
|
void StopMonitoring();
|
||||||
|
|
||||||
std::vector<std::string> WatchedFiles() const;
|
std::vector<std::string> WatchedFiles() const;
|
||||||
|
|||||||
@@ -963,7 +963,7 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule(
|
|||||||
(type == cmStateEnums::OBJECT_LIBRARY) ||
|
(type == cmStateEnums::OBJECT_LIBRARY) ||
|
||||||
(type == cmStateEnums::GLOBAL_TARGET) ||
|
(type == cmStateEnums::GLOBAL_TARGET) ||
|
||||||
(type == cmStateEnums::UTILITY)) {
|
(type == cmStateEnums::UTILITY)) {
|
||||||
std::string name = target->GetName();
|
std::string const& name = target->GetName();
|
||||||
if (emittedTargets.insert(name).second) {
|
if (emittedTargets.insert(name).second) {
|
||||||
path = "... ";
|
path = "... ";
|
||||||
path += name;
|
path += name;
|
||||||
|
|||||||
@@ -180,26 +180,23 @@ protected:
|
|||||||
while (cmSystemTools::GetLineFromStream(fin, line)) {
|
while (cmSystemTools::GetLineFromStream(fin, line)) {
|
||||||
if (cmHasLiteralPrefix(line.c_str(), "#include")) {
|
if (cmHasLiteralPrefix(line.c_str(), "#include")) {
|
||||||
// if it is an include line then create a string class
|
// if it is an include line then create a string class
|
||||||
std::string currentline = line;
|
size_t qstart = line.find('\"', 8);
|
||||||
size_t qstart = currentline.find('\"', 8);
|
|
||||||
size_t qend;
|
size_t qend;
|
||||||
// if a quote is not found look for a <
|
// if a quote is not found look for a <
|
||||||
if (qstart == std::string::npos) {
|
if (qstart == std::string::npos) {
|
||||||
qstart = currentline.find('<', 8);
|
qstart = line.find('<', 8);
|
||||||
// if a < is not found then move on
|
// if a < is not found then move on
|
||||||
if (qstart == std::string::npos) {
|
if (qstart == std::string::npos) {
|
||||||
cmSystemTools::Error("unknown include directive ",
|
cmSystemTools::Error("unknown include directive ", line.c_str());
|
||||||
currentline.c_str());
|
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
qend = currentline.find('>', qstart + 1);
|
qend = line.find('>', qstart + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qend = currentline.find('\"', qstart + 1);
|
qend = line.find('\"', qstart + 1);
|
||||||
}
|
}
|
||||||
// extract the file being included
|
// extract the file being included
|
||||||
std::string includeFile =
|
std::string includeFile = line.substr(qstart + 1, qend - qstart - 1);
|
||||||
currentline.substr(qstart + 1, qend - qstart - 1);
|
|
||||||
// see if the include matches the regular expression
|
// see if the include matches the regular expression
|
||||||
if (!this->IncludeFileRegularExpression.find(includeFile)) {
|
if (!this->IncludeFileRegularExpression.find(includeFile)) {
|
||||||
if (this->Verbose) {
|
if (this->Verbose) {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ static void getCMakeInputs(const cmGlobalGenerator* gg,
|
|||||||
std::vector<std::string>* tmpFiles)
|
std::vector<std::string>* tmpFiles)
|
||||||
{
|
{
|
||||||
const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot() + '/';
|
const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot() + '/';
|
||||||
const std::vector<cmMakefile*> makefiles = gg->GetMakefiles();
|
std::vector<cmMakefile*> const& makefiles = gg->GetMakefiles();
|
||||||
for (auto it = makefiles.begin(); it != makefiles.end(); ++it) {
|
for (auto it = makefiles.begin(); it != makefiles.end(); ++it) {
|
||||||
const std::vector<std::string> listFiles = (*it)->GetListFiles();
|
const std::vector<std::string> listFiles = (*it)->GetListFiles();
|
||||||
|
|
||||||
@@ -850,7 +850,7 @@ static Json::Value DumpTargetsList(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Json::Value DumpProjectList(const cmake* cm, const std::string config)
|
static Json::Value DumpProjectList(const cmake* cm, std::string const& config)
|
||||||
{
|
{
|
||||||
Json::Value result = Json::arrayValue;
|
Json::Value result = Json::arrayValue;
|
||||||
|
|
||||||
@@ -1059,7 +1059,7 @@ cmServerResponse cmServerProtocol1_0::ProcessGlobalSettings(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void setBool(const cmServerRequest& request, const std::string& key,
|
static void setBool(const cmServerRequest& request, const std::string& key,
|
||||||
std::function<void(bool)> setter)
|
std::function<void(bool)> const& setter)
|
||||||
{
|
{
|
||||||
if (request.Data[key].isNull()) {
|
if (request.Data[key].isNull()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user