diff options
author | Zufu Liu <unknown> | 2019-05-24 12:23:46 +1000 |
---|---|---|
committer | Zufu Liu <unknown> | 2019-05-24 12:23:46 +1000 |
commit | 363c7f6ae1050ce8c74f4c35a4fb485f82bcc27a (patch) | |
tree | 7cbb8d1c53bb8e998057429acab197a528f22f39 /src | |
parent | 221471a32eeec9cb5d135993562b6911686c0b3e (diff) | |
download | scintilla-mirror-363c7f6ae1050ce8c74f4c35a4fb485f82bcc27a.tar.gz |
Optimize SCI_GETCURLINE by avoiding per-character calls.
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.cxx | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index e8bfb2cc1..07b05dbc9 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -6438,11 +6438,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { } PLATFORM_ASSERT(wParam > 0); char *ptr = CharPtrFromSPtr(lParam); - unsigned int iPlace = 0; - for (Sci::Position iChar = lineStart; iChar < lineEnd && iPlace < wParam - 1; iChar++) { - ptr[iPlace++] = pdoc->CharAt(iChar); - } - ptr[iPlace] = '\0'; + const Sci::Position len = std::min<uptr_t>(lineEnd - lineStart, wParam - 1); + pdoc->GetCharRange(ptr, lineStart, len); + ptr[len] = '\0'; return sel.MainCaret() - lineStart; } |