From cf5cb97c12a9fccf2427d318cbec5c7146856067 Mon Sep 17 00:00:00 2001 From: zhangzepeng Date: Mon, 7 Aug 2023 15:57:39 +0800 Subject: [PATCH] =?UTF-8?q?=E2=80=98fix=EF=BC=9A=E8=A7=A3=E5=86=B3crash?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzepeng --- .../trace/component/chart/SpProcessChart.ts | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/ide/src/trace/component/chart/SpProcessChart.ts b/ide/src/trace/component/chart/SpProcessChart.ts index 713f6ee7..7f9723b2 100644 --- a/ide/src/trace/component/chart/SpProcessChart.ts +++ b/ide/src/trace/component/chart/SpProcessChart.ts @@ -508,23 +508,21 @@ export class SpProcessChart { let isIntersect = (a: any, b: any): boolean => Math.max(a.startTs + a.dur, b.startTs + b.dur) - Math.min(a.startTs, b.startTs) < a.dur + b.dur; let depthArray: any = []; - let createDepth = (currentDepth: number, index: number): void => { - if ( - depthArray[currentDepth] == undefined || - !isIntersect(depthArray[currentDepth], asyncFunctions[index]) - ) { - asyncFunctions[index].depth = currentDepth; - depthArray[currentDepth] = asyncFunctions[index]; - } else { - createDepth(++currentDepth, index); - } - }; asyncFunctions.forEach((it, i) => { if (it.dur == -1) { it.dur = (TraceRow.range?.endNS || 0) - it.startTs; it.flag = 'Did not end'; } - createDepth(0, i); + let currentDepth = 0; + let index = i; + while ( + depthArray[currentDepth] !== undefined && + isIntersect(depthArray[currentDepth], asyncFunctions[index]) + ) { + currentDepth++; + } + asyncFunctions[index].depth = currentDepth; + depthArray[currentDepth] = asyncFunctions[index]; }); let max = Math.max(...asyncFunctions.map((it) => it.depth || 0)) + 1; let maxHeight = max * 20; -- Gitee