From e3733bc53e2b99e224a39d28fd7ddce994c56e5e Mon Sep 17 00:00:00 2001 From: Dominic Chen Date: Tue, 15 Nov 2016 01:40:58 +0000 Subject: [analyzer] Minor optimization: avoid setting state if unchanged Summary: Split out optimization from D26061 Reviewers: zaks.anna, dcoughlin Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26642 llvm-svn: 286925 --- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'clang') diff --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp index 4c98f2544b9..a312350a7f3 100644 --- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -398,17 +398,19 @@ ConditionTruthVal RangeConstraintManager::checkNull(ProgramStateRef State, ProgramStateRef RangeConstraintManager::removeDeadBindings(ProgramStateRef state, SymbolReaper& SymReaper) { - + bool Changed = false; ConstraintRangeTy CR = state->get(); - ConstraintRangeTy::Factory& CRFactory = state->get_context(); + ConstraintRangeTy::Factory &CRFactory = state->get_context(); 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(CR); + return Changed ? state->set(CR) : state; } RangeSet -- cgit v1.2.3