Skip to content

Commit

Permalink
move _op check out of the fiber hot path
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Oct 31, 2024
1 parent 62d365d commit 3457750
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-dogs-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

move \_op check out of the fiber hot path
9 changes: 4 additions & 5 deletions packages/effect/src/internal/fiberRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1330,11 +1330,6 @@ export class FiberRuntime<in out A, in out E = never> extends Effectable.Class<A
}
}
try {
if (!("_op" in cur) || !((cur as core.Primitive)._op in this)) {
// @ts-expect-error
absurd(cur)
}

// @ts-expect-error
cur = this.currentTracer.context(
() => {
Expand Down Expand Up @@ -1369,6 +1364,10 @@ export class FiberRuntime<in out A, in out E = never> extends Effectable.Class<A
core.exitFailCause(internalCause.die(op))
}
} catch (e) {
if (cur !== YieldedOp && !Predicate.hasProperty(cur, "_op") || !((cur as core.Primitive)._op in this)) {
// @ts-expect-error
absurd(`Not a valid effect: ${Inspectable.toStringUnknown(cur)}`)
}
if (core.isEffectError(e)) {
cur = core.exitFailCause(e.cause)
} else if (core.isInterruptedException(e)) {
Expand Down

0 comments on commit 3457750

Please sign in to comment.