From 4ee413ba81c8030c195a9166847928054ed01ca4 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 20 Feb 2009 21:44:01 +0000 Subject: [PATCH] allocate and dellocate objc decl list through AST Context instead of with new/delete. With disable-free, this reduces the number of 4/8 byte mallocs from 4793/1541 to 865/456 and also drops other sizes as well. This is a very small perf win, nothing major. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65171 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/DeclObjC.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 4e22ebea16..461bb9697f 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -21,7 +21,7 @@ using namespace clang; //===----------------------------------------------------------------------===// void ObjCListBase::Destroy(ASTContext &Ctx) { - delete[] List; + Ctx.Deallocate(List); NumElts = 0; List = 0; } @@ -30,7 +30,8 @@ void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) { assert(List == 0 && "Elements already set!"); if (Elts == 0) return; // Setting to an empty list is a noop. - List = new void*[Elts]; + + List = new (Ctx) void*[Elts]; NumElts = Elts; memcpy(List, InList, sizeof(void*)*Elts); } -- 2.40.0