From 86db174f89e2719b7ee3b1d35c4ae26906faa7bc Mon Sep 17 00:00:00 2001 From: plainheart Date: Mon, 15 Jul 2024 17:11:09 +0800 Subject: [PATCH] perf(line): prebind context of `_changePolyState` function to current instance rather than create an new function to reduce runtime memory cost (fix #20151) --- src/chart/line/LineView.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/chart/line/LineView.ts b/src/chart/line/LineView.ts index 9672eb720b..be4ff3571e 100644 --- a/src/chart/line/LineView.ts +++ b/src/chart/line/LineView.ts @@ -624,6 +624,8 @@ class LineView extends ChartView { this._symbolDraw = symbolDraw; this._lineGroup = lineGroup; + + this._changePolyState = zrUtil.bind(this._changePolyState, this); } render(seriesModel: LineSeriesModel, ecModel: GlobalModel, api: ExtensionAPI) { @@ -885,9 +887,7 @@ class LineView extends ChartView { toggleHoverEmphasis(polygon, focus, blurScope, emphasisDisabled); } - const changePolyState = (toState: DisplayState) => { - this._changePolyState(toState); - }; + const changePolyState = this._changePolyState; data.eachItemGraphicEl(function (el) { // Switch polyline / polygon state if element changed its state.