Skip to content

Commit

Permalink
fix: slice replace cloneDeep consider about performance
Browse files Browse the repository at this point in the history
  • Loading branch information
skie1997 committed Aug 24, 2023
1 parent 76bbf31 commit 25cbde4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions packages/vscale/src/log-scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
* 逆反函数
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions packages/vscale/src/symlog-scale.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 25cbde4

Please sign in to comment.