perf(content): remove exception-driven setup probes

This commit is contained in:
Erik 2026-07-24 15:12:21 +02:00
parent f05afc07c1
commit 230a7df454
11 changed files with 598 additions and 47 deletions

View file

@ -103,6 +103,57 @@ public interface IDatReaderWriter : IDisposable, IDatObjectSource {
/// Resolves a data ID to all possible databases and types.
/// </summary>
public IEnumerable<IdResolution> ResolveId(uint id);
/// <summary>
/// Resolves one data ID using acdream's canonical precedence without
/// materializing a result collection: Portal, HighRes, Language, Cell.
/// Production's concrete adapter overrides this with direct B-tree probes.
/// </summary>
bool TryResolvePreferred(
uint id,
[NotNullWhen(true)] out IDatDatabase? database,
out DBObjType type)
{
IDatDatabase? highRes = null;
DBObjType highResType = DBObjType.Unknown;
IDatDatabase? language = null;
DBObjType languageType = DBObjType.Unknown;
IDatDatabase? cell = null;
DBObjType cellType = DBObjType.Unknown;
foreach (IdResolution resolution in ResolveId(id))
{
if (ReferenceEquals(resolution.Database, Portal))
{
database = resolution.Database;
type = resolution.Type;
return true;
}
if (ReferenceEquals(resolution.Database, HighRes))
{
highRes = resolution.Database;
highResType = resolution.Type;
}
else if (ReferenceEquals(resolution.Database, Language))
{
language = resolution.Database;
languageType = resolution.Type;
}
else if (ReferenceEquals(resolution.Database, Cell))
{
cell = resolution.Database;
cellType = resolution.Type;
}
}
database = highRes ?? language ?? cell;
type = highRes is not null
? highResType
: language is not null
? languageType
: cellType;
return database is not null;
}
}
/// <summary>