Quickly checking that a string belongs to a small set

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • gperf

    mirror of git.savannah.gnu.org/gperf.git with more features. gitlab has the issues

  • Nginx

    An official read-only mirror of http://hg.nginx.org/nginx/ which is updated hourly. Pull requests on GitHub cannot be accepted and will be automatically closed. The proper way to submit changes to nginx is via the nginx development mailing list, see http://nginx.org/en/docs/contributing_changes.html

  • nginx uses switch on a combination of length + specific known characters as part of a similar optimization.

    https://github.com/nginx/nginx/blob/9c7a2c7ce4ad02a36df1bb0e...

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • string-case

    Excessive macro that generates decision trees for small sets of strings

  • This reminds me of the Paul Khuong's string-case macro in Common Lisp.

    https://github.com/pkhuong/string-case/blob/master/string-ca...

  • nbperf

    Improved NetBSD's Perfect Hash Generation Tool v3

  • asm

    Go library providing algorithms optimized to leverage the characteristics of modern CPUs (by segmentio)

  • We took a similar approach in our JSON decoder. We needed to support sets (JSON object keys) that aren't necessarily known until runtime, and strings that are up to 16 bytes in length.

    We got better performance with a linear scan and SIMD matching than with a hash table or a perfect hashing scheme.

    See https://github.com/segmentio/asm/pull/57 (AMD64) and https://github.com/segmentio/asm/pull/65 (ARM64). Here's how it's used in the JSON decoder: https://github.com/segmentio/encoding/pull/101

  • encoding

    Go package containing implementations of efficient encoding, decoding, and validation APIs.

  • We took a similar approach in our JSON decoder. We needed to support sets (JSON object keys) that aren't necessarily known until runtime, and strings that are up to 16 bytes in length.

    We got better performance with a linear scan and SIMD matching than with a hash table or a perfect hashing scheme.

    See https://github.com/segmentio/asm/pull/57 (AMD64) and https://github.com/segmentio/asm/pull/65 (ARM64). Here's how it's used in the JSON decoder: https://github.com/segmentio/encoding/pull/101

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts