View on Asset Store (opens in new tab)
Package details
- Latest version
- 1.0
- Last updated
- First released
- Unity version
- 2022.3.13 or later
- Package size
- 142 KB
- Files
- 9
- Views in the past week
- 5
Price tracking
- Last checked
- Tracked since
- Lowest recorded
- $4.99 on
Keywords
String Atom
High-performance interned string type for Unity/C#. Ensures one shared Str instance per unique text for ultra-fast equality checks, thread-safe access, and built-in pool statistics.
Affiliate link · Purchases support this site
Price history
Last 6 months
USDAsset preview
1 / 1
String Atom video 1
About this asset
Str is a lightweight, production-ready interned string implementation for Unity/C#. It turns frequently used identifiers (keys, tags, event names, type IDs) into shared Str objects stored in a global table. For the same input text, Str.Create(string) always returns the same Str instance, which makes comparisons very fast and predictable in hot paths.
From the publisher's Asset Store listing.
Technical details
- String interning (shared instances). Str.Create(string) returns one shared Str object per unique string value.
- Fast equality checks. Compare Str instances directly instead of repeating ordinal string comparisons.
- Thread-safe access. Uses ReaderWriterLockSlim: many readers at once, exclusive writes only when a new string is added.
- Convenient empty handling. Str.empty is a shared empty value, and Str.IsNullOrEmpty(Str) checks null or empty quickly.
- Pool metrics for profiling. Track growth with strCount, symbolsCount, and maxStrLength to spot unbounded string usage early.
- Sorting support. Implements IComparable for deterministic ordering when needed.
Typical Use Cases IDs and names in gameplay/engine code (states, actions, events, message types) Dictionary keys in hot paths (state machines, behavior trees, ECS-like code) Tags, feature flags, and protocol identifiers
Best Practices: Str is intended for stable identifiers, not unbounded user input. Because the intern table is global and persistent, avoid interning values like GUIDs, chat messages, or large dynamic strings. Use Str.String/ToString() mainly at boundaries (UI, logs, serialization).If your project relies heavily on string keys, Str offers a fast, clean alternative to raw string values while keeping your code readable and profiling-friendly.