From 3badd996bf40d25400ce40bf89aea92cd90b1b35 Mon Sep 17 00:00:00 2001 From: Rick Giles Date: Wed, 25 Dec 2002 13:07:08 +0000 Subject: [PATCH] performance improvement - eliminate multiple instance creation for context HashMap. Still at the top of the performance list of Checkstyle non-parsing methods. --- .../com/puppycrawl/tools/checkstyle/TreeWalker.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/TreeWalker.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/TreeWalker.java index 5fe38d4c4..00ca51e96 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/TreeWalker.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/TreeWalker.java @@ -118,6 +118,8 @@ public final class TreeWalker /** context of child components */ private Context mChildContext; + + private Map mContext = new HashMap(); /** * HACK - a reference to a private "mParent" field in DetailAST. @@ -439,10 +441,10 @@ public final class TreeWalker (ArrayList) mTokenToChecks.get( TokenTypes.getTokenName(aAST.getType())); if (visitors != null) { - final Map ctx = new HashMap(); + mContext.clear(); for (int i = 0; i < visitors.size(); i++) { final Check check = (Check) visitors.get(i); - check.setTokenContext(ctx); + check.setTokenContext(mContext); check.visitToken(aAST); } }