From: John McCall Date: Sun, 16 May 2010 02:09:32 +0000 (+0000) Subject: Avoid doing two switches in TypeLoc's initialize() loop. The optimizer X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7eb914b1398e636845ce4ae8dd7022f72429d8c9;p=clang Avoid doing two switches in TypeLoc's initialize() loop. The optimizer can probably do this for us, but it's actually somewhat nicer to write it out here. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103893 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/TypeLoc.cpp b/lib/AST/TypeLoc.cpp index fd9fbc1918..e66738a65d 100644 --- a/lib/AST/TypeLoc.cpp +++ b/lib/AST/TypeLoc.cpp @@ -92,9 +92,20 @@ namespace { /// recursively, as if the entire tree had been written in the /// given location. void TypeLoc::initializeImpl(TypeLoc TL, SourceLocation Loc) { - do { - TypeLocInitializer(Loc).Visit(TL); - } while ((TL = TL.getNextTypeLoc())); + while (true) { + switch (TL.getTypeLocClass()) { +#define ABSTRACT_TYPELOC(CLASS, PARENT) +#define TYPELOC(CLASS, PARENT) \ + case CLASS: { \ + CLASS##TypeLoc TLCasted = cast(TL); \ + TLCasted.initializeLocal(Loc); \ + TL = TLCasted.getNextTypeLoc(); \ + if (!TL) return; \ + continue; \ + } +#include "clang/AST/TypeLocNodes.def" + } + } } namespace {