Skip to main content

Performance

LidPnEntry fields changed from String to Arc<str> (#811) LidPnEntry.lid and .phone_number are now Arc<str>. LidPnCache::add clones the entry’s own Arcs as the map keys for both lookup directions, so each identifier lives once per mapping instead of once as a key and again inside the entry. This cache is unbounded by design (no TTL, no capacity ceiling — matching WAWebLidPnCache), so per-entry byte savings compound over the full contact base: roughly 40–80 bytes per mapping, or ~0.5–1 MB retained for a process that has learned 10k LID-PN mappings.

Migration

Constructors are source-compatible. LidPnEntry::new and LidPnEntry::with_timestamp accept impl Into<Arc<str>>, so both String and &str arguments continue to compile without changes. Direct field reads return Arc<str> instead of String. Code that accesses .lid or .phone_number directly needs a deref for &str comparisons:
// Before
assert_eq!(entry.lid, some_string);

// After
assert_eq!(&*entry.lid, some_string);
// or
assert_eq!(entry.lid.as_ref(), some_string);
Display and format strings work unchanged — Arc<str> implements Display. get_phone_number return type unchanged. It still returns String (cost-identical to before). Wire/persistence unchanged. Arc<str> serializes as a plain JSON string, so persisted lid_pn_mapping rows and custom CacheStore backends are unaffected.

Summary

BeforeAfter
LidPnEntry.lid / .phone_number typeStringArc<str>
Constructor argument typesStringimpl Into<Arc<str>> (String/&str both work)
get_phone_number return typeStringString (unchanged)
Heap allocations per mapping in cache~4 strings~2 strings (shared)
Wire/persistence formatJSON stringJSON string (unchanged)