瀏覽代碼

cmListFileContext: Implement LessThanComparable.

Move wrapping existing code from cmMakefile, and simplify the
implementation there.
Stephen Kelly 10 年之前
父節點
當前提交
e96b5d14f9
共有 4 個文件被更改,包括 11 次插入23 次删除
  1. 8 0
      Source/cmListFileCache.cxx
  2. 1 0
      Source/cmListFileCache.h
  3. 1 3
      Source/cmMakefile.cxx
  4. 1 20
      Source/cmMakefile.h

+ 8 - 0
Source/cmListFileCache.cxx

@@ -431,3 +431,11 @@ std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)
     }
   return os;
 }
+
+bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs)
+{
+  if(lhs.FilePath != rhs.FilePath)
+    return lhs.FilePath < rhs.FilePath;
+
+  return lhs.Line < rhs.Line;
+}

+ 1 - 0
Source/cmListFileCache.h

@@ -62,6 +62,7 @@ struct cmListFileContext
 };
 
 std::ostream& operator<<(std::ostream&, cmListFileContext const&);
+bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs);
 
 struct cmListFileFunction: public cmListFileContext
 {

+ 1 - 3
Source/cmMakefile.cxx

@@ -4943,9 +4943,7 @@ bool cmMakefile::SetPolicyVersion(const char *version)
 //----------------------------------------------------------------------------
 bool cmMakefile::HasCMP0054AlreadyBeenReported() const
 {
-  cmCMP0054Id id(this->GetExecutionContext());
-
-  return !this->CMP0054ReportedIds.insert(id).second;
+  return !this->CMP0054ReportedIds.insert(this->GetExecutionContext()).second;
 }
 
 //----------------------------------------------------------------------------

+ 1 - 20
Source/cmMakefile.h

@@ -386,26 +386,7 @@ public:
     */
   cmPolicies *GetPolicies() const;
 
-  struct cmCMP0054Id
-  {
-    cmCMP0054Id(cmListFileContext const& context):
-        Context(context)
-    {
-
-    }
-
-    bool operator< (cmCMP0054Id const& id) const
-    {
-      if(this->Context.FilePath != id.Context.FilePath)
-        return this->Context.FilePath < id.Context.FilePath;
-
-      return this->Context.Line < id.Context.Line;
-    }
-
-    cmListFileContext Context;
-  };
-
-  mutable std::set<cmCMP0054Id> CMP0054ReportedIds;
+  mutable std::set<cmListFileContext> CMP0054ReportedIds;
 
   /**
    * Determine if the given context, name pair has already been reported