mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Dont repeatedly lookup the word iterator
This commit is contained in:
parent
a547ffd26e
commit
c75f20a875
@ -276,20 +276,22 @@ public:
|
|||||||
IteratorDescription state;
|
IteratorDescription state;
|
||||||
state.language = ""; state.script = USCRIPT_COMMON;
|
state.language = ""; state.script = USCRIPT_COMMON;
|
||||||
int32_t start_script_block_at = offset;
|
int32_t start_script_block_at = offset;
|
||||||
|
auto word_iterator = std::ref(ensure_lang_iterator(state.language));
|
||||||
while (offset < str.length()) {
|
while (offset < str.length()) {
|
||||||
UChar32 ch = str.char32At(offset);
|
UChar32 ch = str.char32At(offset);
|
||||||
if (at_script_boundary(state, ch)) {
|
if (at_script_boundary(state, ch)) {
|
||||||
if (offset > start_script_block_at) {
|
if (offset > start_script_block_at) {
|
||||||
if ((rc = tokenize_script_block(
|
if ((rc = tokenize_script_block(
|
||||||
str, start_script_block_at, offset,
|
str, start_script_block_at, offset,
|
||||||
for_query, callback, callback_ctx, ensure_lang_iterator(state.language))) != SQLITE_OK) return rc;
|
for_query, callback, callback_ctx, word_iterator)) != SQLITE_OK) return rc;
|
||||||
}
|
}
|
||||||
start_script_block_at = offset;
|
start_script_block_at = offset;
|
||||||
|
word_iterator = ensure_lang_iterator(state.language);
|
||||||
}
|
}
|
||||||
offset = str.moveIndex32(offset, 1);
|
offset = str.moveIndex32(offset, 1);
|
||||||
}
|
}
|
||||||
if (offset > start_script_block_at) {
|
if (offset > start_script_block_at) {
|
||||||
rc = tokenize_script_block(str, start_script_block_at, offset, for_query, callback, callback_ctx, ensure_lang_iterator(state.language));
|
rc = tokenize_script_block(str, start_script_block_at, offset, for_query, callback, callback_ctx, word_iterator);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user