Skip to content

Commit b082910

Browse files
committed
Initialize PlainLineTokenizer only if needed
1 parent d9b7232 commit b082910

File tree

1 file changed

+3
-5
lines changed
  • opengrok-indexer/src/main/java/org/opengrok/indexer/search/context

1 file changed

+3
-5
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/Context.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public class Context {
6363
private final Query query;
6464
private final QueryBuilder qbuilder;
6565
private final LineMatcher[] m;
66-
PlainLineTokenizer tokens;
6766
String queryAsURI;
6867

6968
/**
@@ -97,8 +96,6 @@ public Context(Query query, QueryBuilder qbuilder) {
9796
m = qm.getMatchers(query, TOKEN_FIELDS);
9897
if (m != null) {
9998
buildQueryAsURI(qbuilder.getQueries());
100-
//System.err.println("Found Matchers = "+ m.length + " for " + query);
101-
tokens = new PlainLineTokenizer((Reader) null);
10299
}
103100
}
104101

@@ -367,9 +364,9 @@ public boolean getContext(Reader in, Writer out, String urlPrefix,
367364
if (in == null) {
368365
return anything;
369366
}
370-
int charsRead;
371-
boolean truncated = false;
372367

368+
PlainLineTokenizer tokens = new PlainLineTokenizer(null);
369+
boolean truncated = false;
373370
boolean lim = limit;
374371
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
375372
if (!env.isQuickContextScan()) {
@@ -378,6 +375,7 @@ public boolean getContext(Reader in, Writer out, String urlPrefix,
378375

379376
if (lim) {
380377
char[] buffer = new char[MAXFILEREAD];
378+
int charsRead;
381379
try {
382380
charsRead = in.read(buffer);
383381
if (charsRead == MAXFILEREAD) {

0 commit comments

Comments
 (0)