perf(content): remove exception-driven setup probes
This commit is contained in:
parent
f05afc07c1
commit
230a7df454
11 changed files with 598 additions and 47 deletions
|
|
@ -146,6 +146,53 @@ public sealed class DatCollectionAdapter : IDatReaderWriter {
|
|||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Direct, allocation-free production lookup. Portal precedence is
|
||||
/// load-bearing: the legacy ResolveId ordering is HighRes-first and its
|
||||
/// callers historically re-sorted the materialized results to make Portal
|
||||
/// win. Encode that rule once instead.
|
||||
/// </summary>
|
||||
public bool TryResolvePreferred(
|
||||
uint id,
|
||||
[NotNullWhen(true)] out IDatDatabase? database,
|
||||
out DBObjType type) {
|
||||
if (TryResolve(_portal, id, out type)) {
|
||||
database = _portal;
|
||||
return true;
|
||||
}
|
||||
if (TryResolve(_highRes, id, out type)) {
|
||||
database = _highRes;
|
||||
return true;
|
||||
}
|
||||
if (TryResolve(_language, id, out type)) {
|
||||
database = _language;
|
||||
return true;
|
||||
}
|
||||
if (TryResolve(_cell, id, out type)) {
|
||||
database = _cell;
|
||||
return true;
|
||||
}
|
||||
|
||||
database = null;
|
||||
type = DBObjType.Unknown;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool TryResolve(
|
||||
DatDatabaseWrapper database,
|
||||
uint id,
|
||||
out DBObjType type) {
|
||||
DatDatabase raw = database.RawDatabase;
|
||||
if (raw.Tree.TryGetFile(id, out _)) {
|
||||
type = raw.TypeFromId(id);
|
||||
if (type != DBObjType.Unknown)
|
||||
return true;
|
||||
}
|
||||
|
||||
type = DBObjType.Unknown;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TrySave<T>(T obj, int iteration = 0) where T : IDBObj =>
|
||||
throw new NotSupportedException("DatCollectionAdapter is read-only.");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue