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

Valeriy Savchenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 16 03:51:24 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGdc8a77de7db7: [analyzer] ProjectMap: Do not serialize fields with default values (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81568/new/

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.271031.patch
Type: text/x-patch
Size: 882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200616/bb13854f/attachment-0001.bin>


More information about the cfe-commits mailing list