diff options
author | Neil <nyamatongwe@gmail.com> | 2023-03-02 22:02:19 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2023-03-02 22:02:19 +1100 |
commit | 43ba96d61994db084e61b31df278d2d87c1f313c (patch) | |
tree | 9ec2084b3a8594434889fb622f2fe7c5446dc0a9 /src/EditView.cxx | |
parent | c61df8742a4865ac9c67f8ed017248b82fe5574e (diff) | |
download | scintilla-mirror-43ba96d61994db084e61b31df278d2d87c1f313c.tar.gz |
Add multithreaded wrap to significantly improve performance of wrapping large
files.
Diffstat (limited to 'src/EditView.cxx')
-rw-r--r-- | src/EditView.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx index 259ebf30d..09a20eda3 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -395,7 +395,7 @@ void LayoutSegments(IPositionCache *pCache, * Copy the given @a line and its styles from the document into local arrays. * Also determine the x position at which each character starts. */ -void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width) { +void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width, bool callerMultiThreaded) { if (!ll) return; const Sci::Line line = ll->LineNumber(); @@ -491,7 +491,7 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt const size_t threadsForLength = std::max(1, numCharsInLine / bytesPerLayoutThread); size_t threads = std::min<size_t>({ segments.size(), threadsForLength, maxLayoutThreads }); - if (!surface->SupportsFeature(Supports::ThreadSafeMeasureWidths)) { + if (!surface->SupportsFeature(Supports::ThreadSafeMeasureWidths) || callerMultiThreaded) { threads = 1; } @@ -499,6 +499,7 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt const bool textUnicode = CpUtf8 == model.pdoc->dbcsCodePage; const bool multiThreaded = threads > 1; + const bool multiThreadedContext = multiThreaded || callerMultiThreaded; IPositionCache *pCache = posCache.get(); // If only 1 thread needed then use the main thread, else spin up multiple @@ -508,8 +509,8 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt for (size_t th = 0; th < threads; th++) { // Find relative positions of everything except for tabs std::future<void> fut = std::async(policy, - [pCache, surface, &vstyle, &ll, &segments, &nextIndex, textUnicode, multiThreaded]() { - LayoutSegments(pCache, surface, vstyle, ll, segments, nextIndex, textUnicode, multiThreaded); + [pCache, surface, &vstyle, &ll, &segments, &nextIndex, textUnicode, multiThreadedContext]() { + LayoutSegments(pCache, surface, vstyle, ll, segments, nextIndex, textUnicode, multiThreadedContext); }); futures.push_back(std::move(fut)); } |