Type Alias regex_automata::util::captures::CaptureNameMap

source ·
type CaptureNameMap = HashMap<Arc<str>, SmallIndex>;
Expand description

A map from capture group name to its corresponding capture group index.

This type is actually wrapped inside a Vec indexed by pattern ID on a GroupInfo, since multiple patterns may have the same capture group name. That is, each pattern gets its own namespace of capture group names.

Perhaps a more memory efficient representation would be HashMap<(PatternID, Arc), usize>, but this makes it difficult to look up a capture index by name without producing a Arc<str>, which requires an allocation. To fix this, I think we’d need to define our own unsized type or something? Anyway, I didn’t give this much thought since it probably doesn’t matter much in the grand scheme of things. But it did stand out to me as mildly wasteful.

Aliased Type§

struct CaptureNameMap { /* private fields */ }