[PATCH] D81568: [analyzer] ProjectMap: Do not serialize fields with default values

Valeriy Savchenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 10 06:32:10 PDT 2020


vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81568

Files:
  clang/utils/analyzer/ProjectMap.py


Index: clang/utils/analyzer/ProjectMap.py
===================================================================
--- clang/utils/analyzer/ProjectMap.py
+++ clang/utils/analyzer/ProjectMap.py
@@ -118,4 +118,17 @@
 
     @staticmethod
     def _convert_infos_to_dicts(projects: List[ProjectInfo]) -> List[JSON]:
-        return [project._asdict() for project in projects]
+        return [ProjectMap._convert_info_to_dict(project)
+                for project in projects]
+
+    @staticmethod
+    def _convert_info_to_dict(project: ProjectInfo) -> JSON:
+        whole_dict = project._asdict()
+        defaults = project._field_defaults
+
+        # there is no need in serializing fields with default values
+        for field, default_value in defaults.items():
+            if whole_dict[field] == default_value:
+                del whole_dict[field]
+
+        return whole_dict


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81568.269820.patch
Type: text/x-patch
Size: 882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200610/6d27a8c3/attachment.bin>


More information about the cfe-commits mailing list