From 25cbde40f4612375d556ace015f04e5d7ba295ba Mon Sep 17 00:00:00 2001 From: skie1997 Date: Thu, 24 Aug 2023 14:49:58 +0800 Subject: [PATCH] fix: slice replace cloneDeep consider about performance --- packages/vscale/src/log-scale.ts | 5 ++--- packages/vscale/src/symlog-scale.ts | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/vscale/src/log-scale.ts b/packages/vscale/src/log-scale.ts index 9bcded8..e0644e1 100644 --- a/packages/vscale/src/log-scale.ts +++ b/packages/vscale/src/log-scale.ts @@ -3,7 +3,6 @@ import { ContinuousScale } from './continuous-scale'; import { ScaleEnum } from './type'; import { logp, nice, powp, logNegative, expNegative, identity } from './utils/utils'; import type { ContinuousScaleType, NiceOptions, NiceType } from './interface'; -import { cloneDeep } from '@visactor/vutils'; /** * 逆反函数 @@ -211,7 +210,7 @@ export class LogScale extends ContinuousScale { niceMin(): this { const maxD = this._domain[this._domain.length - 1]; this.nice(); - const niceDomain = cloneDeep(this._domain); + const niceDomain = this._domain.slice(); if (this._domain) { niceDomain[niceDomain.length - 1] = maxD; @@ -229,7 +228,7 @@ export class LogScale extends ContinuousScale { niceMax(): this { const minD = this._domain[0]; this.nice(); - const niceDomain = cloneDeep(this._domain); + const niceDomain = this._domain.slice(); if (this._domain) { niceDomain[0] = minD; diff --git a/packages/vscale/src/symlog-scale.ts b/packages/vscale/src/symlog-scale.ts index c24e737..75eb2bc 100644 --- a/packages/vscale/src/symlog-scale.ts +++ b/packages/vscale/src/symlog-scale.ts @@ -1,4 +1,3 @@ -import { cloneDeep } from '@visactor/vutils'; import type { ContinuousScaleType, NiceOptions, NiceType } from './interface'; import { LinearScale } from './linear-scale'; import { ScaleEnum } from './type'; @@ -111,7 +110,7 @@ export class SymlogScale extends LinearScale { niceMin(): this { const maxD = this._domain[this._domain.length - 1]; this.nice(); - const niceDomain = cloneDeep(this._domain); + const niceDomain = this._domain.slice(); if (this._domain) { niceDomain[niceDomain.length - 1] = maxD; @@ -129,7 +128,7 @@ export class SymlogScale extends LinearScale { niceMax(): this { const minD = this._domain[0]; this.nice(); - const niceDomain = cloneDeep(this._domain); + const niceDomain = this._domain.slice(); if (this._domain) { niceDomain[0] = minD;