Преглед на файлове

VS: Cache the list of xaml and resx headers

Speed up VS project generation with many such headers.
Dmitry Kochkin преди 8 години
родител
ревизия
73a6d4566a
променени са 2 файла, в които са добавени 23 реда и са изтрити 7 реда
  1. 19 7
      Source/cmGeneratorTarget.cxx
  2. 4 0
      Source/cmGeneratorTarget.h

+ 19 - 7
Source/cmGeneratorTarget.cxx

@@ -711,12 +711,18 @@ void cmGeneratorTarget::GetExternalObjects(
   IMPLEMENT_VISIT(ExternalObjects);
 }
 
-void cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs,
+void cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& headers,
                                                const std::string& config) const
 {
-  ResxData data;
-  IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
-  srcs = data.ExpectedResxHeaders;
+  HeadersCacheType::const_iterator it = this->ResxHeadersCache.find(config);
+  if (it == this->ResxHeadersCache.end()) {
+    ResxData data;
+    IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
+    it = this->ResxHeadersCache
+           .insert(std::make_pair(config, data.ExpectedResxHeaders))
+           .first;
+  }
+  headers = it->second;
 }
 
 void cmGeneratorTarget::GetResxSources(std::vector<cmSourceFile const*>& srcs,
@@ -748,9 +754,15 @@ void cmGeneratorTarget::GetCertificates(std::vector<cmSourceFile const*>& data,
 void cmGeneratorTarget::GetExpectedXamlHeaders(std::set<std::string>& headers,
                                                const std::string& config) const
 {
-  XamlData data;
-  IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData)
-  headers = data.ExpectedXamlHeaders;
+  HeadersCacheType::const_iterator it = this->XamlHeadersCache.find(config);
+  if (it == this->XamlHeadersCache.end()) {
+    XamlData data;
+    IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData)
+    it = this->XamlHeadersCache
+           .insert(std::make_pair(config, data.ExpectedXamlHeaders))
+           .first;
+  }
+  headers = it->second;
 }
 
 void cmGeneratorTarget::GetExpectedXamlSources(std::set<std::string>& srcs,

+ 4 - 0
Source/cmGeneratorTarget.h

@@ -739,6 +739,10 @@ private:
   bool ComputePDBOutputDir(const std::string& kind, const std::string& config,
                            std::string& out) const;
 
+  typedef std::map<std::string, std::set<std::string> > HeadersCacheType;
+  mutable HeadersCacheType ResxHeadersCache;
+  mutable HeadersCacheType XamlHeadersCache;
+
 public:
   const std::vector<const cmGeneratorTarget*>& GetLinkImplementationClosure(
     const std::string& config) const;