mirror of
https://github.com/galacean/engine.git
synced 2026-06-20 15:26:09 +08:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user