You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/07/09 16:02:18 UTC

[echarts] 02/02: refact(data): indices should not keep after clone

This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch dataset-perf
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit ed75a2e7fc723e1392955ed37553206109212bd9
Author: pissang <bm...@gmail.com>
AuthorDate: Sat Jul 10 00:01:15 2021 +0800

    refact(data): indices should not keep after clone
---
 src/data/DataStorage.ts | 16 +++++++---------
 src/data/SeriesData.ts  |  3 ++-
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/data/DataStorage.ts b/src/data/DataStorage.ts
index 85a1b85..36a615b 100644
--- a/src/data/DataStorage.ts
+++ b/src/data/DataStorage.ts
@@ -686,13 +686,9 @@ class DataStorage {
       */
      map(dims: DimensionIndex[], cb: MapCb): DataStorage {
         // TODO only clone picked chunks.
-         const target = this.clone(dims);
+         const target = this.clone(dims, true);
          const targetChunks = target._chunks;
 
-         // Following properties are all immutable.
-         // So we can reference to the same value
-         target._indices = this._indices;
-         target.getRawIndex = this.getRawIndex;
 
          const tmpRetValue = [];
          const dimSize = dims.length;
@@ -1001,7 +997,7 @@ class DataStorage {
       *
       * @param clonedDims Determine which dims to clone. Will share the data if not specified.
       */
-     clone(clonedDims?: number[]): DataStorage {
+     clone(clonedDims?: number[], cloneIndices?: boolean): DataStorage {
         const target = new DataStorage();
         const chunks = this._chunks;
         const clonedDimsMap = clonedDims && reduce(clonedDims, (obj, dimIdx) => {
@@ -1020,6 +1016,11 @@ class DataStorage {
             target._chunks = chunks;
         }
         this._copyCommonProps(target);
+
+        if (cloneIndices) {
+            target._indices = this._cloneIndices();
+        }
+        target._updateGetRawIdx();
         return target;
      }
 
@@ -1051,9 +1052,6 @@ class DataStorage {
 
         target._extent = clone(this._extent);
         target._rawExtent = clone(this._rawExtent);
-        target._indices = this._cloneIndices();
-
-        target._updateGetRawIdx();
      }
 
      private _cloneIndices() {
diff --git a/src/data/SeriesData.ts b/src/data/SeriesData.ts
index 553a225..a97cd68 100644
--- a/src/data/SeriesData.ts
+++ b/src/data/SeriesData.ts
@@ -82,7 +82,7 @@ type MapCb<Ctx> = (this: CtxOrList<Ctx>, ...args: any) => ParsedValue | ParsedVa
 
 const TRANSFERABLE_PROPERTIES = [
     'hasItemOption', '_nameList', '_idList', '_invertedIndicesMap',
-    '_rawData', '_dimValueGetter', '_store',
+    '_rawData', '_dimValueGetter',
     '_nameDimIdx', '_idDimIdx', '_nameRepeatCount'
 ];
 const CLONE_PROPERTIES = [
@@ -1155,6 +1155,7 @@ class SeriesData<
         }
 
         transferProperties(list, this);
+        list._store = this._store.clone();
 
         return list;
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org