FastHasher (src/fast_hash.rs)

ladybird · Libraries/LibJS/JIT/Rust/src/fast_hash.rs · rust · BSD-2-Clause
dev-tools

Fast hasher implementation for Rust hash maps used in the compiler.

// Source: https://github.com/LadybirdBrowser/ladybird | License: BSD-2-Clause | Copyright 2018-present, the Ladybird developers
// Provided via justclaw.it.com; keep this notice with the code.
/*
 * Copyright (c) 2026-present, the Ladybird developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

//! Hash maps and sets with a fast hasher, for the compiler's keys: node
//! ids, cells and small tuples of them, which no attacker chooses, so they
//! need no protection against collisions made on purpose.

use std::hash::BuildHasherDefault;
use std::hash::Hasher;

/// The hasher of rustc's `FxHasher`: one rotate, xor and multiply per word.
#[derive(Debug, Clone, Copy, Default)]
pub struct FastHasher(u64);

const SEED: u64 = 0x51_7c_c1_b7_27_22_0a_95;

impl FastHasher {
    fn add(&mut self,

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key