From: Dominic Chen Date: Tue, 15 Nov 2016 01:40:58 +0000 (+0000) Subject: [analyzer] Minor optimization: avoid setting state if unchanged X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=400a9bf83c05e714e10c39bf3e8d62778a2df6f5;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286925 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp b/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp index 4c98f2544b..a312350a7f 100644 --- a/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ b/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