@calcit/procs 0.9.3 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/js-list.mjs +6 -1
- package/lib/js-map.mjs +7 -1
- package/lib/package.json +1 -1
- package/package.json +1 -1
- package/ts-src/js-list.mts +8 -1
- package/ts-src/js-map.mts +9 -1
package/lib/js-list.mjs
CHANGED
|
@@ -112,7 +112,12 @@ export class CalcitSliceList {
|
|
|
112
112
|
this.end = value.length;
|
|
113
113
|
}
|
|
114
114
|
turnListMode() {
|
|
115
|
-
|
|
115
|
+
if (this.cachedTreeListRef != null) {
|
|
116
|
+
return this.cachedTreeListRef;
|
|
117
|
+
}
|
|
118
|
+
let ret = new CalcitList(initTernaryTreeListFromRange(this.value, this.start, this.end));
|
|
119
|
+
this.cachedTreeListRef = ret;
|
|
120
|
+
return ret;
|
|
116
121
|
}
|
|
117
122
|
len() {
|
|
118
123
|
return this.end - this.start;
|
package/lib/js-map.mjs
CHANGED
|
@@ -179,14 +179,20 @@ export class CalcitSliceMap {
|
|
|
179
179
|
throw new Error("unknown data for map");
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
+
/** convert to tree map when needed, also cached in case converted over and over again */
|
|
182
183
|
turnMap() {
|
|
184
|
+
if (this.cachedTreeMapRef != null) {
|
|
185
|
+
return this.cachedTreeMapRef;
|
|
186
|
+
}
|
|
183
187
|
var dict = [];
|
|
184
188
|
let halfLength = this.chunk.length >> 1;
|
|
185
189
|
for (let idx = 0; idx < halfLength; idx++) {
|
|
186
190
|
dict.push([this.chunk[idx << 1], this.chunk[(idx << 1) + 1]]);
|
|
187
191
|
}
|
|
188
192
|
let value = initTernaryTreeMapFromArray(dict);
|
|
189
|
-
|
|
193
|
+
let ret = new CalcitMap(value);
|
|
194
|
+
this.cachedTreeMapRef = ret;
|
|
195
|
+
return ret;
|
|
190
196
|
}
|
|
191
197
|
len() {
|
|
192
198
|
return this.chunk.length >> 1;
|
package/lib/package.json
CHANGED
package/package.json
CHANGED
package/ts-src/js-list.mts
CHANGED
|
@@ -123,6 +123,8 @@ export class CalcitSliceList {
|
|
|
123
123
|
start: number;
|
|
124
124
|
end: number;
|
|
125
125
|
cachedHash: Hash;
|
|
126
|
+
/** reference to converted list */
|
|
127
|
+
cachedTreeListRef: CalcitList;
|
|
126
128
|
constructor(value: Array<CalcitValue>) {
|
|
127
129
|
if (value == null) {
|
|
128
130
|
value = []; // dirty, better handled from outside
|
|
@@ -134,7 +136,12 @@ export class CalcitSliceList {
|
|
|
134
136
|
this.end = value.length;
|
|
135
137
|
}
|
|
136
138
|
turnListMode(): CalcitList {
|
|
137
|
-
|
|
139
|
+
if (this.cachedTreeListRef != null) {
|
|
140
|
+
return this.cachedTreeListRef;
|
|
141
|
+
}
|
|
142
|
+
let ret = new CalcitList(initTernaryTreeListFromRange(this.value, this.start, this.end));
|
|
143
|
+
this.cachedTreeListRef = ret;
|
|
144
|
+
return ret;
|
|
138
145
|
}
|
|
139
146
|
len() {
|
|
140
147
|
return this.end - this.start;
|
package/ts-src/js-map.mts
CHANGED
|
@@ -194,6 +194,8 @@ export class CalcitSliceMap {
|
|
|
194
194
|
cachedHash: Hash;
|
|
195
195
|
/** in arrayMode, only flatten values, instead of tree structure */
|
|
196
196
|
chunk: CalcitValue[];
|
|
197
|
+
/** reference to generated HashMap in tree structure */
|
|
198
|
+
cachedTreeMapRef?: CalcitMap;
|
|
197
199
|
constructor(value: CalcitValue[]) {
|
|
198
200
|
if (value == null) {
|
|
199
201
|
this.chunk = [];
|
|
@@ -203,14 +205,20 @@ export class CalcitSliceMap {
|
|
|
203
205
|
throw new Error("unknown data for map");
|
|
204
206
|
}
|
|
205
207
|
}
|
|
208
|
+
/** convert to tree map when needed, also cached in case converted over and over again */
|
|
206
209
|
turnMap(): CalcitMap {
|
|
210
|
+
if (this.cachedTreeMapRef != null) {
|
|
211
|
+
return this.cachedTreeMapRef;
|
|
212
|
+
}
|
|
207
213
|
var dict: Array<[CalcitValue, CalcitValue]> = [];
|
|
208
214
|
let halfLength = this.chunk.length >> 1;
|
|
209
215
|
for (let idx = 0; idx < halfLength; idx++) {
|
|
210
216
|
dict.push([this.chunk[idx << 1], this.chunk[(idx << 1) + 1]]);
|
|
211
217
|
}
|
|
212
218
|
let value = initTernaryTreeMapFromArray(dict);
|
|
213
|
-
|
|
219
|
+
let ret = new CalcitMap(value);
|
|
220
|
+
this.cachedTreeMapRef = ret;
|
|
221
|
+
return ret;
|
|
214
222
|
}
|
|
215
223
|
len() {
|
|
216
224
|
return this.chunk.length >> 1;
|