.agents/skills/performance-fixer/references/bcl-patterns/collections.md
Sizing, specialized lookups, and set-search primitives for the managed layer. See ../hot-paths/handles-and-collections.md for the object-tracking specifics and ../decision-framework.md for the rubric.
Dictionary/List/ConcurrentDictionary with capacity (and
concurrencyLevel) when the count is known or estimable.HandleDictionary, SKRuntimeEffect/glyph-path caches.SearchValues<T> for repeated char/byte-set searchstatic readonly SearchValues<char> (from SearchValues.Create) and pass it to
IndexOfAny/ContainsAny over spans (SVG path-data tokenizing, separator/invalid-char scans).IndexOfAny(char[]), rebuilt delimiter arrays, or open-coded membership loops.#if NET8_0_OR_GREATER, fall back to the manual scan
· ABI: internal.ContainsAny when only existence mattersspan.ContainsAny(searchValues) instead of span.IndexOfAny(searchValues) >= 0.FrozenDictionary/FrozenSet for static lookup tables built once and queried many times
(named colors, codec/extension tables).Dictionary rebuilt or probed on a hot path.Dictionary · ABI: internal.CollectionsMarshal for in-place accessCollectionsMarshal.AsSpan(list) / GetValueRefOrAddDefault to read/update in place.Avoid LINQ (Where/Select/Any/Count/ToList) in tight/hot loops — the enumerator and closure
allocate; a plain for over a Span/array is allocation-free.