From 09bf85ad0e4155aec405978bb9019462819d4fff Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Mon, 6 Dec 2021 12:35:13 -0800 Subject: [PATCH] Improved performance with lots of raw leaks displayed --- BeefRT/dbg/gc_raw.cpp | 7 +++++++ IDE/src/IDEApp.bf | 24 ++++++++++++------------ IDE/src/ui/OutputPanel.bf | 33 +++++++++++++++++++++++++++++---- 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/BeefRT/dbg/gc_raw.cpp b/BeefRT/dbg/gc_raw.cpp index e02a54bf..605564b4 100644 --- a/BeefRT/dbg/gc_raw.cpp +++ b/BeefRT/dbg/gc_raw.cpp @@ -421,8 +421,13 @@ void BFGC::RawShutdown() gDbgErrorString = errorStr; gDbgErrorString += "\n"; + int passLeakCount = 0; + for (auto& rawLeak : mSweepInfo.mRawLeaks) { + if (passLeakCount == 20000) // Only display so many... + break; + Beefy::String typeName; if (rawLeak.mRawAllocData->mType != NULL) typeName = rawLeak.mRawAllocData->mType->GetFullName() + "*"; @@ -451,6 +456,8 @@ void BFGC::RawShutdown() if (gDbgErrorString.length() < 256) gDbgErrorString += StrFormat(" %s\n", leakStr.c_str()); + + passLeakCount++; } BF_ASSERT(mSweepInfo.mLeakCount > 0); diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index 21570d6f..0131b705 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -12309,16 +12309,16 @@ namespace IDE } hadMessages = true; int paramIdx = msg.IndexOf(' '); - String cmd = scope String(); - String param = scope String(); + StringView cmd = default; + StringView param = default; if (paramIdx > 0) { - cmd.Append(msg, 0, paramIdx); - param.Append(msg, paramIdx + 1); + cmd = msg.Substring(0, paramIdx); + param = msg.Substring(paramIdx + 1); } else - cmd.Append(msg); + cmd = msg; bool isOutput = (cmd == "msg") || (cmd == "dbgEvalMsg") || (cmd == "log"); if (cmd == "msgLo") @@ -12356,7 +12356,7 @@ namespace IDE while (true) { - String errorMsg = null; + StringView errorMsg = default; int infoPos = param.IndexOf("\x01"); if (infoPos == 0) @@ -12368,7 +12368,7 @@ namespace IDE if (endPos == -1) break; String leakStr = scope String(param, 1, endPos - 1); - param.Remove(0, endPos + 1); + param.RemoveFromStart(endPos + 1); int itemIdx = 0; for (var itemView in leakStr.Split('\t')) { @@ -12410,12 +12410,12 @@ namespace IDE tempStr.Clear(); tempStr.Append(param, 0, infoPos); errorMsg = tempStr; - param.Remove(0, infoPos); + param.RemoveFromStart(infoPos); } else errorMsg = param; - if (errorMsg != null) + if (!errorMsg.IsEmpty) { if (isFirstMsg) { @@ -12427,19 +12427,19 @@ namespace IDE mOutputPanel.Update(); } - OutputLineSmart(scope String("ERROR: ", errorMsg)); + OutputLineSmart(scope String("ERROR: ", scope String(errorMsg))); if (gApp.mRunningTestScript) { // The 'OutputLineSmart' would already call 'Fail' when running test scripts } else { - Fail(errorMsg); + Fail(scope String(errorMsg)); } isFirstMsg = false; } else - Output(errorMsg); + Output(scope String(errorMsg)); } if (infoPos == -1) diff --git a/IDE/src/ui/OutputPanel.bf b/IDE/src/ui/OutputPanel.bf index cc40a3fc..8d002fa1 100644 --- a/IDE/src/ui/OutputPanel.bf +++ b/IDE/src/ui/OutputPanel.bf @@ -84,6 +84,8 @@ namespace IDE.ui List mQueuedDisplayChanges = new List() ~ delete _; List mInlineWidgets = new List() ~ delete _; public int32 mHoverWatchLine; + public float mLastInlineMinY; + public float mLastInlineMaxY; public override SourceEditWidget EditWidget { @@ -198,10 +200,10 @@ namespace IDE.ui } } - public override void Update() + public override void UpdateAll() { - base.Update(); - + base.UpdateAll(); + var editData = mOutputWidget.mEditWidgetContent.mData; int lineStartZero = -1; @@ -211,6 +213,8 @@ namespace IDE.ui Debug.Assert(lineStartZero <= editData.mTextLength); } + bool hasNewInlineWidgets = false; + UpdateHoverWatch(); if (mQueuedText.Length > 0) { @@ -232,7 +236,7 @@ namespace IDE.ui if (queuedDisplayChange.mWidget != null) { var widget = queuedDisplayChange.mWidget; - mOutputWidget.mEditWidgetContent.AddWidget(queuedDisplayChange.mWidget); + hasNewInlineWidgets = true; mOutputWidget.Content.GetLineCharAtIdx(startLen + queuedDisplayChange.mOfs, out line, out lineChar); mOutputWidget.Content.GetTextCoordAtLineChar(line, lineChar, var xOfs, var yOfs); @@ -257,6 +261,27 @@ namespace IDE.ui mQueuedText.Clear(); mQueuedDisplayChanges.Clear(); } + + float minY = -mOutputWidget.mEditWidgetContent.mY; + float maxY = minY + mOutputWidget.mHeight; + + if ((gApp.mIsUpdateBatchStart) || (hasNewInlineWidgets) || (mLastInlineMinY != minY) || (mLastInlineMaxY != maxY)) + { + for (var inlineWidget in ref mInlineWidgets) + { + bool isVisible = (inlineWidget.mWidget.mY + inlineWidget.mWidget.mHeight >= minY) && (inlineWidget.mWidget.mY < maxY); + if ((inlineWidget.mWidget.mParent != null) != isVisible) + { + if (isVisible) + mOutputWidget.mEditWidgetContent.AddWidget(inlineWidget.mWidget); + else + inlineWidget.mWidget.RemoveSelf(); + } + } + + mLastInlineMinY = minY; + mLastInlineMaxY = maxY; + } } public void WriteSmart(StringView text)