Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 84fb4af

Browse files
committed
Clean up hunspell CheckSpelling
1 parent 7f601b7 commit 84fb4af

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/spellchecker_hunspell.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,23 @@ std::vector<MisspelledRange> HunspellSpellchecker::CheckSpelling(const uint16_t
6060
std::vector<char> utf8_buffer(256);
6161
char *utf8_word = utf8_buffer.data();
6262

63-
bool within_word = false;
6463
size_t word_start = 0;
65-
for (size_t i = 0; i <= utf16_length; i++) {
66-
bool is_alpha = i < utf16_length && std::iswalpha(utf16_text[i]);
67-
64+
bool within_word = false;
65+
for (size_t i = 0; i < utf16_length; i++) {
66+
bool is_word_character = iswalpha(utf16_text[i]);
6867
if (within_word) {
69-
if (!is_alpha) {
68+
if (!is_word_character) {
7069
within_word = false;
7170
const w_char *utf16_word = reinterpret_cast<const w_char *>(utf16_text + word_start);
7271
u16_u8(utf8_word, utf8_buffer.size(), utf16_word, i - word_start);
73-
7472
if (hunspell->spell(utf8_word) == 0) {
7573
MisspelledRange range;
7674
range.start = word_start;
7775
range.end = i;
7876
result.push_back(range);
7977
}
8078
}
81-
} else if (is_alpha) {
79+
} else if (is_word_character) {
8280
word_start = i;
8381
within_word = true;
8482
}

0 commit comments

Comments
 (0)