小珠光输入惰性判断
Use this fallback, not a Merge node, when an input might be empty
- A
- B
- 输出
- 判断
Every now and then a workflow needs a "use this if you have it, otherwise that" gate. Say you've got an optional control image: when one is connected, use it; when it isn't, fall back to a default. The naive move is a Merge or a switch node - but those still compute both branches. XiaozhuguangInputLazyCheck (小珠光输入惰性判断) is the version that only computes the branch it actually uses.
The mechanism is ComfyUI's lazy-evaluation machinery, and it's neat. Input A is a normal, always-evaluated input. Input B is declared lazy: true, which means the engine doesn't evaluate B's upstream at all until this node asks for it. Inside, check_lazy_status looks at A: if A has content, it returns nothing and B's entire upstream stays unexecuted - no wasted samplers, no big model loads, no VRAM spent on a branch you're throwing away. Only when A is None does it request B, and the engine then evaluates just that branch. That "skip the work you don't need" behavior is the whole reason this node exists over a plain selector.
Two inputs, both optional and any-type (* - meaning they accept whatever you connect):
- A - the preferred value. Always evaluated.
- B - the fallback. Lazy; only computed when A is empty.
Two outputs:
- 输出 - whichever value won: A if A had content, else B.
- 判断 - a BOOLEAN telling you which path fired.
falsewhen it output A,truewhen it fell back to B. Wire this into a toggle downstream if you need the rest of the graph to behave differently depending on the fallback.
So the practical shape is: connect your optional thing to A, a Primitive or fixed value to B, and feed 输出 wherever it was going. You can even read 判断 to drive a bypass.
Two things bite people here. First, because B is lazy, anything that relies on B's upstream running for side effects - a save node, a counter - silently won't run when A is present. Lazy means "not evaluated," not "evaluated and ignored." Second, empty matters: it's None that counts as empty, so a genuinely empty but connected value (like an empty string or a zero tensor) will pass the check and be used. If your "optional" input can arrive as a real-but-useless value, normalize it upstream to a disconnect rather than expecting this node to sniff it out.
Install: ComfyUI Manager → search ComfyUI-xiaozhuguang → install → restart, or git clone https://github.com/xiaozhuguang/ComfyUI-xiaozhuguang into custom_nodes. No models, no dependencies. It's one of the pack's quiet little plumbing nodes, but if you're building a workflow that people will reuse with different inputs connected, it's the difference between "fast when it can be" and "always pays for both branches."
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| Aopt | * | — | |
| Bopt | * | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| 输出 | * | — |
| 判断 | BOOLEAN | — |