piece

open override fun piece(other: HyperLogLog): HyperLogLog

The join: element-wise maximum of the two register arrays.

Fast paths (triggered by sparseIndex set in add/emptyPatch):

  • Empty delta (EMPTY): other has no non-zero registers — returns this unchanged.

  • Single-register delta (≥ 0): updates only the one register that add changed, avoiding the O(m) bit-manipulation loop over all 16 384 registers. A byte-level copyOf + one setRegisterInto replaces the full O(m) scan.

  • General case (UNKNOWN): falls back to the full O(m) element-wise merge.

The fast paths matter because the common add/piece idiom (hll = hll.piece(hll.add(x))) would otherwise perform O(m) 6-bit bit-manipulation operations on every call, blocking the browser's single JS thread on wasmJs (the root cause of the Karma "browser disconnected" failures compensated by #768).