diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx index 8e2b5680d2..8e812f2689 100644 --- a/scintilla/src/Document.cxx +++ b/scintilla/src/Document.cxx @@ -118,10 +118,6 @@ void ActionDuration::AddSample(Sci::Position numberActions, double durationOfAct // durationOfActions, numberActions, durationOne, duration_, duration, minDuration, maxDuration); } -double ActionDuration::Duration() const noexcept { - return duration; -} - Sci::Position ActionDuration::ActionsInAllowedTime(double secondsAllowed) const noexcept { const Sci::Position actions = std::clamp(static_cast(secondsAllowed / duration), 8, 0x10000); return actions * unitBytes; diff --git a/scintilla/src/Document.h b/scintilla/src/Document.h index fa4daea039..ba3b348951 100644 --- a/scintilla/src/Document.h +++ b/scintilla/src/Document.h @@ -217,7 +217,9 @@ class ActionDuration { public: static constexpr int InitialBytes = 1024*1024; void AddSample(Sci::Position numberActions, double durationOfActions) noexcept; - double Duration() const noexcept; + double Duration() const noexcept { + return duration; + } Sci::Position ActionsInAllowedTime(double secondsAllowed) const noexcept; }; diff --git a/scintilla/src/EditView.cxx b/scintilla/src/EditView.cxx index 45ad12eacf..39fd9f6086 100644 --- a/scintilla/src/EditView.cxx +++ b/scintilla/src/EditView.cxx @@ -444,10 +444,10 @@ constexpr WrapBreak GetWrapBreakEx(unsigned int ch, bool isUtf8) noexcept { * Also determine the x position at which each character starts. */ int EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width, LayoutLineOption option, int posInLine) { + int wrappedBytes = 0; // only care about time spend on MeasureWidths() const Sci::Line line = ll->LineNumber(); PLATFORM_ASSERT(line < model.pdoc->LinesTotal()); PLATFORM_ASSERT(ll->chars); - int laidBytes = 0; // lower bound, only care time spend on MeasureWidths() const Sci::Position posLineStart = model.pdoc->LineStart(line); // If the line is very long, limit the treatment to a length that should fit in the viewport const Sci::Position posLineEnd = std::min(model.pdoc->LineStart(line + 1), posLineStart + ll->maxLineLength); @@ -588,11 +588,11 @@ int EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSty if (endPos > posInLine && model.IdleTaskTimeExpired()) { // treat remaining text as zero width - //printf("%s(%d, %zd) posInLine=%d, lineLength=%d / %d, laidBytes=%d - %d\n", __func__, - // (int)option, line, posInLine, laidBytes, ll->numCharsInLine, endPos, ll->lastSegmentEnd); + //printf("%s(%d, %zd) posInLine=%d, lineLength=%d / %d, wrappedBytes=%d - %d\n", __func__, + // (int)option, line, posInLine, wrappedBytes, ll->numCharsInLine, endPos, ll->lastSegmentEnd); if (endPos < ll->numCharsInLine) { wholeLine = false; - laidBytes = endPos - ll->lastSegmentEnd; + wrappedBytes = endPos - ll->lastSegmentEnd; ll->lastSegmentEnd = endPos; const XYPOSITION last = ll->positions[endPos]; std::fill(&ll->positions[endPos + 1], &ll->positions[ll->numCharsInLine + 1], last); @@ -603,7 +603,7 @@ int EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSty // Small hack to make lines that end with italics not cut off the edge of the last character if (wholeLine) { - laidBytes = ll->numCharsInLine - ll->lastSegmentEnd; + wrappedBytes = ll->numCharsInLine - ll->lastSegmentEnd; ll->lastSegmentEnd = ll->numCharsInLine; if (lastSegItalics) { ll->positions[ll->numCharsInLine] += vstyle.lastSegItalicsOffset; @@ -772,7 +772,7 @@ int EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSty } } ll->validity = validity; - return laidBytes; + return wrappedBytes; } // Fill the LineLayout bidirectional data fields according to each char style @@ -2633,7 +2633,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan LayoutLine(model, surface, vsDraw, ll, model.wrapWidth, LayoutLineOption::KeepPosition); } #if defined(TIME_PAINTING) - durLayout += ep.Duration(true); + durLayout += ep.Reset(); #endif if (ll) { ll->containsCaret = !hideSelection && (lineDoc == lineCaret) @@ -2665,7 +2665,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan DrawLine(surface, model, vsDraw, ll, lineDoc, visibleLine, xStart, rcLine, subLine, phase); #if defined(TIME_PAINTING) - durPaint += ep.Duration(true); + durPaint += ep.Reset(); #endif // Restore the previous styles for the brace highlights in case layout is in cache. ll->RestoreBracesHighlight(rangeLine, model.braces, bracesIgnoreStyle); diff --git a/scintilla/src/EditView.h b/scintilla/src/EditView.h index 31597ff968..a64b95b3e8 100644 --- a/scintilla/src/EditView.h +++ b/scintilla/src/EditView.h @@ -34,8 +34,8 @@ enum class DrawPhase { }; enum class LayoutLineOption { - AutoUpdate , - ManualUpdate , + AutoUpdate, + ManualUpdate, KeepPosition, }; diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index c67ea7d2ad..fa91678a02 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -1530,34 +1530,6 @@ void Editor::OnLineWrapped(Sci::Line lineDoc, int linesWrapped) { // wsIdle: wrap one page + 100 lines // Return true if wrapping occurred. bool Editor::WrapLines(WrapScope ws) { -//#define WRAP_LINES_TIMING -#ifdef WRAP_LINES_TIMING - struct WrapTiming { - size_t totalBytes; - size_t totalRuns; - double totalDuration; - using Clock = std::chrono::steady_clock; - Clock::time_point startTime; - - void Reset() noexcept { - totalBytes = 0; - totalRuns = 0; - totalDuration = 0; - } - void Add(size_t bytes, double duration) noexcept { - totalBytes += bytes; - ++totalRuns; - totalDuration += duration; - } - double TotalTime() const noexcept { - const auto tpNow = Clock::now(); - const auto duration = std::chrono::duration_cast>(tpNow - startTime); - return duration.count(); - } - }; - - static WrapTiming wrapTiming; -#endif Sci::Line goodTopLine = topLine; bool wrapOccurred = false; if (!Wrapping()) { @@ -1581,13 +1553,6 @@ bool Editor::WrapLines(WrapScope ws) { } // Decide where to start wrapping Sci::Line lineToWrap = wrapPending.start; -#ifdef WRAP_LINES_TIMING - if (lineToWrap == 0) { - printf("%s wrap start ws=%d, modEventMask=%x\n", __func__, ws, modEventMask); - wrapTiming.Reset(); - wrapTiming.startTime = WrapTiming::Clock::now(); - } -#endif Sci::Line lineToWrapEnd = std::min(wrapPending.end, pdoc->LinesTotal()); const Sci::Line lineDocTop = pcs->DocFromDisplay(topLine); const Sci::Line subLineTop = topLine - pcs->DisplayFromDoc(lineDocTop); @@ -1655,9 +1620,6 @@ bool Editor::WrapLines(WrapScope ws) { lineToWrap++; } const double duration = epWrapping.Duration(); -#ifdef WRAP_LINES_TIMING - wrapTiming.Add(bytesBeingWrapped, duration); -#endif durationWrapOneUnit.AddSample(bytesBeingWrapped, duration); goodTopLine = pcs->DisplayFromDoc(lineDocTop) + std::min( @@ -1669,14 +1631,6 @@ bool Editor::WrapLines(WrapScope ws) { if (!partialLine && wrapPending.start >= lineEndNeedWrap) { //printf("%s durationStyleOneUnit: %f\n", __func__, durationWrapOneUnit.Duration()*1e3); wrapPending.Reset(); -#ifdef WRAP_LINES_TIMING - const double totalTime = wrapTiming.TotalTime(); - printf("%s bytes=%zu / %zu, time=%.6f / %.6f, level=%d,\n" - "\tLinesOnScreen=%zd, idleStyling=%d, modEventMask=%x, technology=%d, dbcsCodePage=%d\n", - __func__, wrapTiming.totalBytes, wrapTiming.totalRuns, wrapTiming.totalDuration, totalTime, - view.llc.GetLevel(), LinesOnScreen(), idleStyling, modEventMask, technology, pdoc->dbcsCodePage); - wrapTiming.Reset(); -#endif } } diff --git a/scintilla/src/ElapsedPeriod.h b/scintilla/src/ElapsedPeriod.h index d6f87266ea..ab6a415fbc 100644 --- a/scintilla/src/ElapsedPeriod.h +++ b/scintilla/src/ElapsedPeriod.h @@ -16,12 +16,10 @@ class ElapsedPeriod { /// Capture the moment ElapsedPeriod() noexcept : tp(ElapsedClock::now()) {} /// Return duration as floating point seconds - double Duration(bool reset) noexcept { + double Reset() noexcept { const auto tpNow = ElapsedClock::now(); const auto duration = std::chrono::duration_cast>(tpNow - tp); - if (reset) { - tp = tpNow; - } + tp = tpNow; return duration.count(); }