浏览代码

cmExpandedCommandArgument: add an overload for const char*

Static string comparisons were causing heap allocations just for a
comparison.
Ben Boeckel 7 年之前
父节点
当前提交
901c4a1e05
共有 2 个文件被更改,包括 6 次插入0 次删除
  1. 5 0
      Source/cmExpandedCommandArgument.cxx
  2. 1 0
      Source/cmExpandedCommandArgument.h

+ 5 - 0
Source/cmExpandedCommandArgument.cxx

@@ -24,6 +24,11 @@ bool cmExpandedCommandArgument::WasQuoted() const
   return this->Quoted;
   return this->Quoted;
 }
 }
 
 
+bool cmExpandedCommandArgument::operator==(const char* value) const
+{
+  return this->Value == value;
+}
+
 bool cmExpandedCommandArgument::operator==(std::string const& value) const
 bool cmExpandedCommandArgument::operator==(std::string const& value) const
 {
 {
   return this->Value == value;
   return this->Value == value;

+ 1 - 0
Source/cmExpandedCommandArgument.h

@@ -24,6 +24,7 @@ public:
 
 
   bool WasQuoted() const;
   bool WasQuoted() const;
 
 
+  bool operator==(const char* value) const;
   bool operator==(std::string const& value) const;
   bool operator==(std::string const& value) const;
 
 
   bool empty() const;
   bool empty() const;