Skip to content

Commit 5845fee

Browse files
committed
improve side-effect processing performance by reducing array mutation
1 parent ae9e163 commit 5845fee

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Bacon.coffee

+7-2
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,7 @@ UpdateBarrier = (->
14171417
waiterObs = []
14181418
waiters = {}
14191419
afters = []
1420+
aftersIndex = 0
14201421

14211422
afterTransaction = (f) ->
14221423
if rootEvent
@@ -1471,8 +1472,12 @@ UpdateBarrier = (->
14711472
#console.log("done with tx")
14721473
flush()
14731474
rootEvent = undefined
1474-
while (afters.length > 0)
1475-
afters.shift()()
1475+
while (aftersIndex < afters.length)
1476+
after = afters[aftersIndex]
1477+
aftersIndex++
1478+
after()
1479+
aftersIndex = 0
1480+
afters = []
14761481
result
14771482

14781483
currentEventId = -> if rootEvent then rootEvent.id else undefined

0 commit comments

Comments
 (0)