Spellchecker IDEA-100509 slow on large files / minor - get rid of couple interim strings

This commit is contained in:
Alexey Gopachenko
2013-02-11 10:34:36 +01:00
parent f03e6eb596
commit 45866a320c
2 changed files with 8 additions and 7 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,9 +43,10 @@ public class TextSplitter extends BaseSplitter {
protected void doSplit(@NotNull String text, @NotNull TextRange range, Consumer<TextRange> consumer) {
final WordSplitter ws = WordSplitter.getInstance();
Matcher matcher = EXTENDED_WORD_AND_SPECIAL.matcher(range.substring(text));
Matcher matcher = EXTENDED_WORD_AND_SPECIAL.matcher(text);
matcher.region(range.getStartOffset(), range.getEndOffset());
while (matcher.find()) {
TextRange found = matcherRange(range, matcher);
TextRange found = new TextRange(matcher.start(), matcher.end());
ws.split(text, found, consumer);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,10 +39,10 @@ public class WordSplitter extends BaseSplitter {
if (text == null || range.getLength() <= 1) {
return;
}
Matcher specialMatcher = SPECIAL.matcher(range.substring(text));
Matcher specialMatcher = SPECIAL.matcher(text);
specialMatcher.region(range.getStartOffset(), range.getEndOffset());
if (specialMatcher.find()) {
TextRange found = matcherRange(range, specialMatcher);
TextRange found = new TextRange(specialMatcher.start(), specialMatcher.end());
addWord(consumer, true, found);
}
else {