Skip to content

Commit 1287baf

Browse files
committed
Use new Array micro optimization
1 parent 17c2dc7 commit 1287baf

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

asyncLogic.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ class AsyncLogicEngine {
173173
// END OPTIMIZER BLOCK //
174174

175175
if (Array.isArray(logic)) {
176-
const res = []
176+
const res = new Array(logic.length)
177177
// Note: In the past, it used .map and Promise.all; this can be changed in the future
178178
// if we want it to run concurrently.
179-
for (let i = 0; i < logic.length; i++) res.push(await this.run(logic[i], data, { above }))
179+
for (let i = 0; i < logic.length; i++) res[i] = await this.run(logic[i], data, { above })
180180
return res
181181
}
182182

logic.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ class LogicEngine {
154154
// END OPTIMIZER BLOCK //
155155

156156
if (Array.isArray(logic)) {
157-
const res = []
158-
for (let i = 0; i < logic.length; i++) res.push(this.run(logic[i], data, { above }))
157+
const res = new Array(logic.length)
158+
for (let i = 0; i < logic.length; i++) res[i] = this.run(logic[i], data, { above })
159159
return res
160160
}
161161

utilities/coerceArray.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Coerces a value into an array.
44
* This is used for unary value operations.
55
*/
6-
export function coerceArray (value, skip = false) {
7-
if (skip) return value
6+
export function coerceArray (value) {
87
return Array.isArray(value) ? value : [value]
98
}

0 commit comments

Comments
 (0)