Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
f2fa7904
I
incubator-echarts
项目概览
半栈学徒
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f2fa7904
编写于
9月 18, 2020
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(list): fix some null access issues after perf refactor before.
上级
e106d642
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
19 deletion
+31
-19
src/data/List.ts
src/data/List.ts
+31
-19
未找到文件。
src/data/List.ts
浏览文件 @
f2fa7904
...
@@ -446,6 +446,7 @@ class List<
...
@@ -446,6 +446,7 @@ class List<
// Clear
// Clear
this
.
_storage
=
{};
this
.
_storage
=
{};
this
.
_storageArr
=
[];
this
.
_indices
=
null
;
this
.
_indices
=
null
;
this
.
_nameList
=
nameList
||
[];
this
.
_nameList
=
nameList
||
[];
...
@@ -517,6 +518,7 @@ class List<
...
@@ -517,6 +518,7 @@ class List<
appendValues
(
values
:
any
[][],
names
?:
string
[]):
void
{
appendValues
(
values
:
any
[][],
names
?:
string
[]):
void
{
const
chunkSize
=
this
.
_chunkSize
;
const
chunkSize
=
this
.
_chunkSize
;
const
storage
=
this
.
_storage
;
const
storage
=
this
.
_storage
;
const
storageArr
=
this
.
_storageArr
;
const
dimensions
=
this
.
dimensions
;
const
dimensions
=
this
.
dimensions
;
const
dimLen
=
dimensions
.
length
;
const
dimLen
=
dimensions
.
length
;
const
rawExtent
=
this
.
_rawExtent
;
const
rawExtent
=
this
.
_rawExtent
;
...
@@ -531,12 +533,18 @@ class List<
...
@@ -531,12 +533,18 @@ class List<
rawExtent
[
dim
]
=
getInitialExtent
();
rawExtent
[
dim
]
=
getInitialExtent
();
}
}
if
(
!
storage
[
dim
])
{
if
(
!
storage
[
dim
])
{
storage
[
dim
]
=
[];
const
store
:
DataValueChunk
[]
=
[];
storage
[
dim
]
=
store
;
storageArr
.
push
(
store
);
}
}
prepareChunks
(
storage
,
this
.
_dimensionInfos
[
dim
],
chunkSize
,
originalChunkCount
,
end
);
prepareChunks
(
storage
,
this
.
_dimensionInfos
[
dim
],
chunkSize
,
originalChunkCount
,
end
);
this
.
_chunkCount
=
storage
[
dim
].
length
;
this
.
_chunkCount
=
storage
[
dim
].
length
;
}
}
const
rawExtentArr
=
zrUtil
.
map
(
dimensions
,
(
dim
)
=>
{
return
rawExtent
[
dim
];
});
const
emptyDataItem
=
new
Array
(
dimLen
);
const
emptyDataItem
=
new
Array
(
dimLen
);
for
(
let
idx
=
start
;
idx
<
end
;
idx
++
)
{
for
(
let
idx
=
start
;
idx
<
end
;
idx
++
)
{
const
sourceIdx
=
idx
-
start
;
const
sourceIdx
=
idx
-
start
;
...
@@ -544,14 +552,14 @@ class List<
...
@@ -544,14 +552,14 @@ class List<
const
chunkOffset
=
idx
%
chunkSize
;
const
chunkOffset
=
idx
%
chunkSize
;
// Store the data by dimensions
// Store the data by dimensions
for
(
let
k
=
0
;
k
<
dimLen
;
k
++
)
{
for
(
let
dimIdx
=
0
;
dimIdx
<
dimLen
;
dimIdx
++
)
{
const
dim
=
dimensions
[
k
];
const
dim
=
dimensions
[
dimIdx
];
const
val
=
this
.
_dimValueGetterArrayRows
(
const
val
=
this
.
_dimValueGetterArrayRows
(
values
[
sourceIdx
]
||
emptyDataItem
,
dim
,
sourceIdx
,
k
values
[
sourceIdx
]
||
emptyDataItem
,
dim
,
sourceIdx
,
dimIdx
)
as
ParsedValueNumeric
;
)
as
ParsedValueNumeric
;
storage
[
dim
][
chunkIndex
][
chunkOffset
]
=
val
;
storage
Arr
[
dimIdx
][
chunkIndex
][
chunkOffset
]
=
val
;
const
dimRawExtent
=
rawExtent
[
dim
];
const
dimRawExtent
=
rawExtent
Arr
[
dimIdx
];
val
<
dimRawExtent
[
0
]
&&
(
dimRawExtent
[
0
]
=
val
);
val
<
dimRawExtent
[
0
]
&&
(
dimRawExtent
[
0
]
=
val
);
val
>
dimRawExtent
[
1
]
&&
(
dimRawExtent
[
1
]
=
val
);
val
>
dimRawExtent
[
1
]
&&
(
dimRawExtent
[
1
]
=
val
);
}
}
...
@@ -577,6 +585,7 @@ class List<
...
@@ -577,6 +585,7 @@ class List<
const
chunkSize
=
this
.
_chunkSize
;
const
chunkSize
=
this
.
_chunkSize
;
const
rawData
=
this
.
_rawData
;
const
rawData
=
this
.
_rawData
;
const
storage
=
this
.
_storage
;
const
storage
=
this
.
_storage
;
const
storageArr
=
this
.
_storageArr
;
const
dimensions
=
this
.
dimensions
;
const
dimensions
=
this
.
dimensions
;
const
dimLen
=
dimensions
.
length
;
const
dimLen
=
dimensions
.
length
;
const
dimensionInfoMap
=
this
.
_dimensionInfos
;
const
dimensionInfoMap
=
this
.
_dimensionInfos
;
...
@@ -587,6 +596,7 @@ class List<
...
@@ -587,6 +596,7 @@ class List<
let
nameDimIdx
;
let
nameDimIdx
;
const
originalChunkCount
=
this
.
_chunkCount
;
const
originalChunkCount
=
this
.
_chunkCount
;
for
(
let
i
=
0
;
i
<
dimLen
;
i
++
)
{
for
(
let
i
=
0
;
i
<
dimLen
;
i
++
)
{
const
dim
=
dimensions
[
i
];
const
dim
=
dimensions
[
i
];
if
(
!
rawExtent
[
dim
])
{
if
(
!
rawExtent
[
dim
])
{
...
@@ -602,7 +612,9 @@ class List<
...
@@ -602,7 +612,9 @@ class List<
}
}
if
(
!
storage
[
dim
])
{
if
(
!
storage
[
dim
])
{
storage
[
dim
]
=
[];
const
store
:
DataValueChunk
[]
=
[];
storage
[
dim
]
=
store
;
storageArr
.
push
(
store
);
}
}
prepareChunks
(
storage
,
dimInfo
,
chunkSize
,
originalChunkCount
,
end
);
prepareChunks
(
storage
,
dimInfo
,
chunkSize
,
originalChunkCount
,
end
);
...
@@ -610,13 +622,9 @@ class List<
...
@@ -610,13 +622,9 @@ class List<
this
.
_chunkCount
=
storage
[
dim
].
length
;
this
.
_chunkCount
=
storage
[
dim
].
length
;
}
}
const
storageArr
:
DataValueChunk
[][]
=
this
.
_storageArr
=
[];
const
rawExtentArr
=
zrUtil
.
map
(
dimensions
,
(
dim
)
=>
{
const
rawExtentArr
=
[];
return
rawExtent
[
dim
];
for
(
let
k
=
0
;
k
<
dimLen
;
k
++
)
{
});
const
dim
=
dimensions
[
k
];
storageArr
.
push
(
storage
[
dim
]);
rawExtentArr
.
push
(
rawExtent
[
dim
]);
}
let
dataItem
=
[]
as
OptionDataItem
;
let
dataItem
=
[]
as
OptionDataItem
;
for
(
let
idx
=
start
;
idx
<
end
;
idx
++
)
{
for
(
let
idx
=
start
;
idx
<
end
;
idx
++
)
{
...
@@ -632,14 +640,14 @@ class List<
...
@@ -632,14 +640,14 @@ class List<
const
chunkOffset
=
idx
%
chunkSize
;
const
chunkOffset
=
idx
%
chunkSize
;
// Store the data by dimensions
// Store the data by dimensions
for
(
let
k
=
0
;
k
<
dimLen
;
k
++
)
{
for
(
let
dimIdx
=
0
;
dimIdx
<
dimLen
;
dimIdx
++
)
{
const
dim
=
dimensions
[
k
];
const
dim
=
dimensions
[
dimIdx
];
const
dimStorage
=
storageArr
[
k
][
chunkIndex
];
const
dimStorage
=
storageArr
[
dimIdx
][
chunkIndex
];
// PENDING NULL is empty or zero
// PENDING NULL is empty or zero
const
val
=
this
.
_dimValueGetter
(
dataItem
,
dim
,
idx
,
k
)
as
ParsedValueNumeric
;
const
val
=
this
.
_dimValueGetter
(
dataItem
,
dim
,
idx
,
dimIdx
)
as
ParsedValueNumeric
;
dimStorage
[
chunkOffset
]
=
val
;
dimStorage
[
chunkOffset
]
=
val
;
const
dimRawExtent
=
rawExtentArr
[
k
];
const
dimRawExtent
=
rawExtentArr
[
dimIdx
];
val
<
dimRawExtent
[
0
]
&&
(
dimRawExtent
[
0
]
=
val
);
val
<
dimRawExtent
[
0
]
&&
(
dimRawExtent
[
0
]
=
val
);
val
>
dimRawExtent
[
1
]
&&
(
dimRawExtent
[
1
]
=
val
);
val
>
dimRawExtent
[
1
]
&&
(
dimRawExtent
[
1
]
=
val
);
}
}
...
@@ -741,6 +749,10 @@ class List<
...
@@ -741,6 +749,10 @@ class List<
// Because in v8 access array by number variable is faster than access object by string variable
// Because in v8 access array by number variable is faster than access object by string variable
// Not sure why but the optimization just works.
// Not sure why but the optimization just works.
getByDimIdx
(
dimIdx
:
number
,
idx
:
number
):
ParsedValue
{
getByDimIdx
(
dimIdx
:
number
,
idx
:
number
):
ParsedValue
{
if
(
!
(
idx
>=
0
&&
idx
<
this
.
_count
))
{
return
NaN
;
}
const
dimStore
=
this
.
_storageArr
[
dimIdx
];
const
dimStore
=
this
.
_storageArr
[
dimIdx
];
const
chunkSize
=
this
.
_chunkSize
;
const
chunkSize
=
this
.
_chunkSize
;
if
(
!
dimStore
)
{
if
(
!
dimStore
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录