refactor(shader-lab): drop dead branch in familyIndexOf

`FamilyMemberIndex` is built from `FamilyMembers` with the same key set,
and callers only enter familyIndexOf after confirming the family exists
in `FamilyMembers`. The `if (!map) return -1` branch is therefore
unreachable — replace with a non-null assertion.

One-line function now.
This commit is contained in:
chenmo.gl
2026-04-20 18:02:41 +08:00
parent 8fa20636a6
commit cd051f05d0

View File

@@ -100,12 +100,11 @@ for (const key in FamilyMembers) {
FamilyMemberIndex.set(family, indexMap);
}
// Locate a concrete type in a family. Returns index on hit, -1 on miss
// Locate a concrete type in a family. Returns index on hit, -1 on miss.
// The `!` is safe: callers only reach here after confirming the family is in
// `FamilyMembers`, and `FamilyMemberIndex` is built from the same key set.
function familyIndexOf(family: GenericType, type: NonGenericGalaceanType): number {
const map = FamilyMemberIndex.get(family);
if (!map) return -1;
const idx = map.get(type);
return idx === undefined ? -1 : idx;
return FamilyMemberIndex.get(family)!.get(type) ?? -1;
}
const BuiltinFunctionTable: Map<string, BuiltinFunction[]> = new Map();