MCPcopy Create free account
hub / github.com/Effect-TS/effect / mergeLeavesInner

Function mergeLeavesInner

packages/effect/src/internal/hashMap/node.ts:345–363  ·  view source on GitHub ↗
(
  edit: number,
  shift: number,
  h1: number,
  n1: Node<K, V>,
  h2: number,
  n2: Node<K, V>
)

Source from the content-addressed store, hash-verified

343}
344
345function mergeLeavesInner<K, V>(
346 edit: number,
347 shift: number,
348 h1: number,
349 n1: Node<K, V>,
350 h2: number,
351 n2: Node<K, V>
352): Node<K, V> | ((child: Node<K, V>) => Node<K, V>) {
353 if (h1 === h2) return new CollisionNode(edit, h1, [n2, n1])
354 const subH1 = hashFragment(shift, h1)
355 const subH2 = hashFragment(shift, h2)
356
357 if (subH1 === subH2) {
358 return (child) => new IndexedNode(edit, toBitmap(subH1) | toBitmap(subH2), [child])
359 } else {
360 const children = subH1 < subH2 ? [n1, n2] : [n2, n1]
361 return new IndexedNode(edit, toBitmap(subH1) | toBitmap(subH2), children)
362 }
363}
364
365function mergeLeaves<K, V>(
366 edit: number,

Callers 1

mergeLeavesFunction · 0.85

Calls 2

hashFragmentFunction · 0.85
toBitmapFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…