MCPcopy Index your code
hub / github.com/Effect-TS/effect / diff

Function diff

packages/effect/src/internal/fiberRefs/patch.ts:45–79  ·  view source on GitHub ↗
(
  oldValue: FiberRefs.FiberRefs,
  newValue: FiberRefs.FiberRefs
)

Source from the content-addressed store, hash-verified

43
44/** @internal */
45export const diff = (
46 oldValue: FiberRefs.FiberRefs,
47 newValue: FiberRefs.FiberRefs
48): FiberRefsPatch.FiberRefsPatch => {
49 const missingLocals = new Map(oldValue.locals)
50 let patch = empty
51 for (const [fiberRef, pairs] of newValue.locals.entries()) {
52 const newValue = Arr.headNonEmpty(pairs)[1]
53 const old = missingLocals.get(fiberRef)
54 if (old !== undefined) {
55 const oldValue = Arr.headNonEmpty(old)[1]
56 if (!equals(oldValue, newValue)) {
57 patch = combine({
58 _tag: OP_UPDATE,
59 fiberRef,
60 patch: fiberRef.diff(oldValue, newValue)
61 })(patch)
62 }
63 } else {
64 patch = combine({
65 _tag: OP_ADD,
66 fiberRef,
67 value: newValue
68 })(patch)
69 }
70 missingLocals.delete(fiberRef)
71 }
72 for (const [fiberRef] of missingLocals.entries()) {
73 patch = combine({
74 _tag: OP_REMOVE,
75 fiberRef
76 })(patch)
77 }
78 return patch
79}
80
81/** @internal */
82export const combine = dual<

Callers

nothing calls this directly

Calls 5

entriesMethod · 0.80
getMethod · 0.65
diffMethod · 0.65
equalsFunction · 0.50
combineFunction · 0.50

Tested by

no test coverage detected