From: Benjamin Kramer Date: Tue, 9 Oct 2012 15:52:25 +0000 (+0000) Subject: Clearing a SmallPtrSet is still expensive, split it out from OverloadCandidateSet... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f5b132f7b373203eab7cf357b01f935bd88087bd;p=clang Clearing a SmallPtrSet is still expensive, split it out from OverloadCandidateSet::clear and don't do it on destruction. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165501 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/Overload.h b/include/clang/Sema/Overload.h index 6ebccbdba6..65ed781f74 100644 --- a/include/clang/Sema/Overload.h +++ b/include/clang/Sema/Overload.h @@ -751,9 +751,11 @@ namespace clang { OverloadCandidateSet(const OverloadCandidateSet &) LLVM_DELETED_FUNCTION; void operator=(const OverloadCandidateSet &) LLVM_DELETED_FUNCTION; + void destroyCandidates(); + public: OverloadCandidateSet(SourceLocation Loc) : Loc(Loc), NumInlineSequences(0){} - ~OverloadCandidateSet() { clear(); } + ~OverloadCandidateSet() { destroyCandidates(); } SourceLocation getLocation() const { return Loc; } diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 600393137d..bdc25ba39c 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -740,13 +740,17 @@ OverloadCandidate::DeductionFailureInfo::getSecondArg() { return 0; } -void OverloadCandidateSet::clear() { +void OverloadCandidateSet::destroyCandidates() { for (iterator i = begin(), e = end(); i != e; ++i) { for (unsigned ii = 0, ie = i->NumConversions; ii != ie; ++ii) i->Conversions[ii].~ImplicitConversionSequence(); if (!i->Viable && i->FailureKind == ovl_fail_bad_deduction) i->DeductionFailure.Destroy(); } +} + +void OverloadCandidateSet::clear() { + destroyCandidates(); NumInlineSequences = 0; Candidates.clear(); Functions.clear();