Skip to content

Text indelpattern dispose

github-actions[bot] edited this page Sep 24, 2026 · 4 revisions

Development build. This page describes main, not a released package. The latest published Lodestar.Text is 0.7.0 — read its documentation.

HomeTextDistances

IndelPattern.Dispose

Returns the equality table to the pool. Scanning afterwards throws.

public void Dispose()

Returns — nothing.

Example — a using statement is the intended shape; this is what it calls.

using Lodestar.Text.Distances;

IndelPattern query = IndelPattern.For("kitten");
int distance = query.Distance("sitting".AsSpan());   // => 5
query.Dispose();

Remarksidempotent, which is why IndelPattern is a class. A struct holding a rented array is trivially copyable, and two copies disposed would return one array twice; the pool would then hand it to two callers at once, which is silent corruption rather than an exception. The one object header this costs is paid once per pattern and amortised over every text the handle scans.

A handle that is never disposed leaks nothing — the array is ordinary managed memory — but the pool has to allocate a replacement for it, which is the cost a using avoids.

Disposal is not thread-safe. Scanning is: the table is only read.

Applies to — net10.0, netstandard2.0.

See alsoIndelPattern, IndelPattern.For.

Clone this wiki locally