TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24829 14
Azrar - a String interning library for C++ with faster comparisons and reduced memory footprint"

Comments and critics are welcome :-)

Github link: [https://github.com/kboutora/Azrar](https://github.com/kboutora/Azrar)

This is a lightweight C++ (14 and +) library for string interning and indexing that can significantly improve performance in applications dealing with repeated string comparisons or using strings as maps key.

The library is header only.

**How it works:**

Instead of working with strings, Azrar maintains a dictionary where each unique string gets assigned a unique index..

Working with these unique indexes makes copying, comparing, and hashing operations substantially faster.

Github link: [https://github.com/kboutora/Azrar](https://github.com/kboutora/Azrar)

**Usage minimalist example:**

include "Azrar.h"
include <map>
include <iostream>

using IdxString = Azrar::StringIndex<uint32_t>;
int main(int , char **)
{

// Expect to print 4 (sizeof (uint32_t))
std::cout << "sizeof(IdxString): " << sizeof(IdxString) << " bytes\n\n";

IdxString city1("seattle");
IdxString city2("seattle");
IdxString city3("portland");

// Fast O(1) comparison (compares integers, not string contents)
if (city1 == city2) {
std::cout << "Same city!\n";
}

// Use as map keys - much faster lookups than std::string
std::map<IdxString, int> population;
population[city1] = 750000;
population[city3] = 650000;

// Access the original string when needed
std::cout << "City: " << city1.c_str() << "\n";
return 0;
}

https://redd.it/1rophrb
@r_cpp
GitHub GitHub - kboutora/Azrar: A library for high performance string interning and indexing A library for high performance string interning and indexing - kboutora/Azrar
More from @r_cpp
  1. Oct 7, 2026Full Meeting C++ 2026 program released https://meetingcpp.com/mcpp/schedule/#2026 https://…
  2. Oct 7, 2026Qt moc now can handle basic C++ modules (Qt 6.12) https://codereview.qt-project.org/c/qt/q…
  3. Oct 7, 2026New to c++ Hello everybody,im new to cpp,and want to learn it,i have some knowledge with C…
  4. Oct 7, 2026Optimizing the Compressed Log Pipeline: https://github.com/Tencent/BqLog/blob/main/docs/Ar…
  5. Oct 7, 2026BqLog 2.6.0: a C++ logging library running on 30M+ devices daily, benchmarked against quil…
  6. Oct 7, 2026BqLog 2.6.0: a C++ logging library running on 30M+ devices daily, benchmarked against quil…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →