(n: number): numberApplies bit manipulation techniques to optimize a hash value.
When to use
Use to improve the bit distribution of a raw numeric hash value.
Details
This function takes a hash value and applies bitwise operations to improve the distribution of hash values, reducing the likelihood of collisions.
Example (Optimizing a hash value)
import { Hash } from "effect"
const rawHash = 1234567890
const optimizedHash = Hash.optimize(rawHash)
console.log(optimizedHash) // optimized hash value
// Often used internally by other hash functions
const stringHash = Hash.optimize(Hash.string("hello"))hashing
Source effect/Hash.ts:2701 lines
export const const optimize: (n: number) => numberApplies bit manipulation techniques to optimize a hash value.
When to use
Use to improve the bit distribution of a raw numeric hash value.
Details
This function takes a hash value and applies bitwise operations to improve
the distribution of hash values, reducing the likelihood of collisions.
Example (Optimizing a hash value)
import { Hash } from "effect"
const rawHash = 1234567890
const optimizedHash = Hash.optimize(rawHash)
console.log(optimizedHash) // optimized hash value
// Often used internally by other hash functions
const stringHash = Hash.optimize(Hash.string("hello"))
optimize = (n: numbern: number): number => (n: numbern & 0xbfffffff) | ((n: numbern >>> 1) & 0x40000000)Referenced by 3 symbols