Skip to content

Commit

Permalink
feat: optimize join function in dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Jul 4, 2024
1 parent de5c9ae commit f801337
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 5 additions & 2 deletions packages/vtable/src/dataset/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
typeSort
} from './statistics-helper';
import { IndicatorDimensionKeyPlaceholder } from '../tools/global';
import { join } from '../tools/join';
/**
* 数据处理模块
*/
Expand Down Expand Up @@ -994,7 +995,8 @@ export class Dataset {
}
});
}
flatRowKey = rowKey.join(this.stringJoinChar);
// flatRowKey = rowKey.join(this.stringJoinChar);
flatRowKey = join(rowKey, this.stringJoinChar);
}

if (typeof colKey === 'string') {
Expand All @@ -1008,7 +1010,8 @@ export class Dataset {
}
});
}
flatColKey = colKey.join(this.stringJoinChar);
// flatColKey = colKey.join(this.stringJoinChar);
flatColKey = join(colKey, this.stringJoinChar);
}
//TODO 原有逻辑 但这里先强制跳过
// if ( rowKey.length === 0 && colKey.length === 0) {
Expand Down
4 changes: 2 additions & 2 deletions packages/vtable/src/layout/pivot-header-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3692,7 +3692,7 @@ export class PivotHeaderLayoutMap implements LayoutMapAPI {
this._getBodyCache.clear();
}
disableUseGetBodyCache() {
this._useGetBodyCache = true;
this._useGetBodyCache = false;
this._getBodyCache.clear();
}
enableUseHeaderPathCache() {
Expand All @@ -3701,7 +3701,7 @@ export class PivotHeaderLayoutMap implements LayoutMapAPI {
this._rowHeaderPathCache.clear();
}
disableUseHeaderPathCache() {
this._useHeaderPathCache = true;
this._useHeaderPathCache = false;
this._colHeaderPathCache.clear();
this._rowHeaderPathCache.clear();
}
Expand Down
12 changes: 12 additions & 0 deletions packages/vtable/src/tools/join.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export function join(strArr: string[], joinChar: string) {
// return strArr.join(joinChar);
let str = '';
for (let i = 0; i < strArr.length; i++) {
str += strArr[i];
if (i !== strArr.length - 1) {
str += joinChar;
}
}

return str;
}

0 comments on commit f801337

Please sign in to comment.