Skip to content

Commit 079975c

Browse files
authored
backport Effect.gen optimization (#5772)
1 parent 62f7636 commit 079975c

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

.changeset/forty-toes-knock.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"effect": patch
3+
---
4+
5+
backport Effect.gen optimization

packages/effect/src/internal/fiberRuntime.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,20 @@ const contOpSuccess = {
194194
cont: core.FromIterator,
195195
value: unknown
196196
) => {
197-
const state = internalCall(() => cont.effect_instruction_i0.next(value))
198-
if (state.done) return core.exitSucceed(state.value)
199-
self.pushStack(cont)
200-
return yieldWrapGet(state.value)
197+
while (true) {
198+
const state = internalCall(() => cont.effect_instruction_i0.next(value))
199+
if (state.done) {
200+
return core.exitSucceed(state.value)
201+
}
202+
const primitive = yieldWrapGet(state.value)
203+
if (!core.exitIsExit(primitive)) {
204+
self.pushStack(cont)
205+
return primitive
206+
} else if (primitive._tag === "Failure") {
207+
return primitive
208+
}
209+
value = primitive.value
210+
}
201211
}
202212
}
203213

0 commit comments

Comments
 (0)