[PATCH] D26642: [analyzer] Minor optimization: avoid setting state if unchanged

Dominic Chen via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 14 17:50:48 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL286925: [analyzer] Minor optimization: avoid setting state if unchanged (authored by ddcc).

Changed prior to commit:
  https://reviews.llvm.org/D26642?vs=77897&id=77929#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26642

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -398,17 +398,19 @@
 ProgramStateRef
 RangeConstraintManager::removeDeadBindings(ProgramStateRef state,
                                            SymbolReaper& SymReaper) {
-
+  bool Changed = false;
   ConstraintRangeTy CR = state->get<ConstraintRange>();
-  ConstraintRangeTy::Factory& CRFactory = state->get_context<ConstraintRange>();
+  ConstraintRangeTy::Factory &CRFactory = state->get_context<ConstraintRange>();
 
   for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) {
     SymbolRef sym = I.getKey();
-    if (SymReaper.maybeDead(sym))
+    if (SymReaper.maybeDead(sym)) {
+      Changed = true;
       CR = CRFactory.remove(CR, sym);
+    }
   }
 
-  return state->set<ConstraintRange>(CR);
+  return Changed ? state->set<ConstraintRange>(CR) : state;
 }
 
 RangeSet


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26642.77929.patch
Type: text/x-patch
Size: 1074 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161115/df28b812/attachment.bin>


More information about the cfe-commits mailing list