Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Feb 25, 2025
1 parent b76cf1b commit 0a0e580
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,21 @@ export async function findDefinition(device: Zh.Device, generateForUnknown = fal
}

// hot path when no external converters present
const candidates =
externalDefinitionsCount > 0
? [].concat(getFromExternalDefinitionsLookup(device.modelID) ?? [], (await getFromIndex(device.modelID)) ?? [])
: await getFromIndex(device.modelID);
let candidates: DefinitionWithExtend[];
if (externalDefinitionsCount > 0) {
candidates = getFromExternalDefinitionsLookup(device.modelID);

if (candidates) {
const builtins = await getFromIndex(device.modelID);
if (builtins) {
candidates.push(...builtins);
}
} else {
candidates = await getFromIndex(device.modelID);
}
} else {
candidates = await getFromIndex(device.modelID);
}

if (!candidates) {
if (!generateForUnknown || device.type === "Coordinator") {
Expand Down

0 comments on commit 0a0e580

Please sign in to comment.