From 45866a320c826ac7706fbdfa1952826ccae15795 Mon Sep 17 00:00:00 2001 From: Alexey Gopachenko Date: Mon, 11 Feb 2013 10:32:27 +0100 Subject: [PATCH] Spellchecker IDEA-100509 slow on large files / minor - get rid of couple interim strings --- .../intellij/spellchecker/inspections/TextSplitter.java | 7 ++++--- .../intellij/spellchecker/inspections/WordSplitter.java | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java index 6327114829a9..bf6e737c1943 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java @@ -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 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); } } diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/WordSplitter.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/WordSplitter.java index fd6204af460f..fc24ee2d0a61 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/WordSplitter.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/WordSplitter.java @@ -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 {