Skip to content

Commit

Permalink
move _op check out of the fiber hot path (#3868)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Oct 31, 2024
1 parent 6f86821 commit 68b5c9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 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: 3 additions & 6 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,7 +1364,9 @@ export class FiberRuntime<in out A, in out E = never> extends Effectable.Class<A
core.exitFailCause(internalCause.die(op))
}
} catch (e) {
if (core.isEffectError(e)) {
if (cur !== YieldedOp && !Predicate.hasProperty(cur, "_op") || !((cur as core.Primitive)._op in this)) {
cur = core.dieMessage(`Not a valid effect: ${Inspectable.toStringUnknown(cur)}`)
} else if (core.isEffectError(e)) {
cur = core.exitFailCause(e.cause)
} else if (core.isInterruptedException(e)) {
cur = core.exitFailCause(
Expand Down

0 comments on commit 68b5c9e

Please sign in to comment.