lookuptable 0.1.1

Static lookup table for an array of values

To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Simple library to generate a static lookup table.

Sometimes you want to generate a lookup table for something. And that lookup table is initialized once and never changes. If you use an AA, it can generate a lot of needless allocations as it's growing the buckets. Not only that, but the items themselves are individual allocations in the GC. If you have a lookup table of 100 items, that's a minimum of 101 allocations, cwhich can put a tax on the GC especially if you only intend to use it for a short time.

This lookup table is generated from known data -- the data must already be known before generating the table, and must have a length. Therefore, it knows how much buckets to allocate, and it can do all in one allocation, reducing the GC load when collecting.

It should be slightly faster than an AA, and much less taxing on GC collections.

Future improvements may include RAII possibilities (using malloc).

An example use case may be an array of headers read from an HTTP connection, where you want to look up values based on the header name. You read the headers into an array, and then generate a lookup table based on that.

  • Steven Schveighoffer
0.1.4 2021-Feb-01
0.1.3 2020-Apr-22
0.1.2 2020-Mar-30
0.1.1 2020-Mar-26
0.1.0 2020-Mar-26
Show all 6 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 4 downloads this month

  • 52 downloads total

Short URL: