@@ -32,7 +32,7 @@ public class KeywordMap {
3232
3333 // A value of 52 will give good performance for most maps.
3434 static private int MAP_LENGTH = 52 ;
35-
35+
3636 /**
3737 * Creates a new <code>KeywordMap</code>.
3838 * @param ignoreCase True if keys are case insensitive
@@ -84,8 +84,8 @@ public byte lookup(Segment text, int offset, int length, boolean paren) {
8484 }
8585 return Token .NULL ;
8686 }
87-
88-
87+
88+
8989 /**
9090 * Checks if a subregion of a <code>Segment</code> is equal to a
9191 * character array.
@@ -98,20 +98,20 @@ static public boolean regionMatches(boolean ignoreCase, Segment text,
9898 int offset , char [] match ) {
9999 int length = offset + match .length ;
100100 char [] textArray = text .array ;
101- if (length > text .offset + text .count )
101+ if (length > text .offset + text .count ) {
102102 return false ;
103- for (int i = offset , j = 0 ; i < length ; i ++, j ++)
104- {
105- char c1 = textArray [i ];
106- char c2 = match [j ];
107- if (ignoreCase )
108- {
109- c1 = Character .toUpperCase (c1 );
110- c2 = Character .toUpperCase (c2 );
111- }
112- if (c1 != c2 )
113- return false ;
103+ }
104+ for (int i = offset , j = 0 ; i < length ; i ++, j ++) {
105+ char c1 = textArray [i ];
106+ char c2 = match [j ];
107+ if (ignoreCase ) {
108+ c1 = Character .toUpperCase (c1 );
109+ c2 = Character .toUpperCase (c2 );
110+ }
111+ if (c1 != c2 ) {
112+ return false ;
114113 }
114+ }
115115 return true ;
116116 }
117117
@@ -127,7 +127,7 @@ public void add(String keyword, byte id, boolean paren) {
127127 map [key ] = new Keyword (keyword .toCharArray (), id , map [key ]);
128128 }
129129
130-
130+
131131 /**
132132 * Returns true if the keyword map is set to be case insensitive,
133133 * false otherwise.
@@ -136,7 +136,7 @@ public boolean getIgnoreCase() {
136136 return ignoreCase ;
137137 }
138138
139-
139+
140140 /**
141141 * Sets if the keyword map should be case insensitive.
142142 * @param ignoreCase True if the keyword map should be case
@@ -146,21 +146,21 @@ public void setIgnoreCase(boolean ignoreCase) {
146146 this .ignoreCase = ignoreCase ;
147147 }
148148
149-
149+
150150 protected int getStringMapKey (String s ) {
151151 return (Character .toUpperCase (s .charAt (0 )) +
152152 Character .toUpperCase (s .charAt (s .length ()-1 )))
153153 % MAP_LENGTH ;
154154 }
155155
156-
156+
157157 protected int getSegmentMapKey (Segment s , int off , int len ) {
158158 return (Character .toUpperCase (s .array [off ]) +
159159 Character .toUpperCase (s .array [off + len - 1 ]))
160160 % MAP_LENGTH ;
161161 }
162162
163-
163+
164164 // private members
165165 private static class Keyword {
166166 public final char [] keyword ;
0 commit comments