#string #interning #cache #hash

yanked chisel-stringtable

Simple hash-based string cache

7 releases

0.1.6 Mar 23, 2023
0.1.5 Mar 23, 2023

#5 in #strings

Download history 48/week @ 2024-07-30 1/week @ 2024-09-17 6/week @ 2024-09-24

92 downloads per month

MIT/Apache

1.5MB
72 lines

Chisel - String Table

Rust

crates.io

Overview

This crate contains a very simple string table which can be used to intern strings by stashing them all within a single data-structure, and then referencing them throughout other areas of a code base using a unique u64 identifier.

Currently there is a single implementation of an interning data structure based on an internal B-Tree index. Nothing very sophisticated going on here at all.

Usage

There really isn't much to it:

    use chisel_stringtable::btree_string_table::BTreeStringTable;
    use chisel_stringtable::common::StringTable;

    let mut table = BTreeStringTable::new();
    let key : u64 = table.add("some value to intern");
    assert_eq!(table.get(key).unwrap(), "some value to intern");
    assert_eq!(format!("Here's me embedded string: {}", table.get(key).unwrap()),
                        "Here's me embedded string: some value to intern")

No runtime deps