From 28753ca5fe15ce2dfa6fe783b818ef5107df1b98 Mon Sep 17 00:00:00 2001 From: Rick Giles Date: Wed, 25 Dec 2002 23:27:31 +0000 Subject: [PATCH] performance improvement: avoiding charAt range checks is worth the cost of toCharArray --- src/checkstyle/com/puppycrawl/tools/checkstyle/api/Utils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/api/Utils.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/api/Utils.java index 6472174dd..0c0d439e7 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/api/Utils.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/api/Utils.java @@ -101,8 +101,9 @@ public final class Utils int aTabWidth) { int len = 0; + final char[] chars = aString.toCharArray(); for (int idx = 0; idx < aToIdx; idx++) { - if (aString.charAt(idx) == '\t') { + if (chars[idx] == '\t') { len = (len / aTabWidth + 1) * aTabWidth; } else {