From 61e290750e36de75bf67d00ff8f43cd7fdcde883 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Thu, 24 Aug 2017 18:28:52 +0300 Subject: [PATCH] Read attribute once, better variable name --- lib/importproject.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 4b6150605..7a80d9bae 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -385,25 +385,26 @@ static void importPropertyGroup(const tinyxml2::XMLElement *node, std::mapAttribute("Label") && std::strcmp(node->Attribute("Label"),"UserMacros")==0) { + const char* labelAttribute = node->Attribute("Label"); + if (labelAttribute && std::strcmp(labelAttribute, "UserMacros") == 0) { for (const tinyxml2::XMLElement *propertyGroup = node->FirstChildElement(); propertyGroup; propertyGroup = propertyGroup->NextSiblingElement()) { const std::string name(propertyGroup->Name()); const char *text = propertyGroup->GetText(); (*variables)[name] = std::string(text ? text : ""); } - } else if (!node->Attribute("Label")) { + } else if (!labelAttribute) { for (const tinyxml2::XMLElement *propertyGroup = node->FirstChildElement(); propertyGroup; propertyGroup = propertyGroup->NextSiblingElement()) { if (std::strcmp(propertyGroup->Name(), "IncludePath") != 0) continue; const char *text = propertyGroup->GetText(); if (!text) continue; - std::string s(text); - std::string::size_type pos = s.find("$(IncludePath)"); + std::string path(text); + std::string::size_type pos = path.find("$(IncludePath)"); if (pos != std::string::npos) - s = s.substr(0,pos) + *includePath + s.substr(pos+14U); - *includePath = s; + path = path.substr(0,pos) + *includePath + path.substr(pos+14U); + *includePath = path; } } }