fix: The starting node of the loop in the loop body should be prohibi…#4287
fix: The starting node of the loop in the loop body should be prohibi…#4287shaohuzhang1 merged 1 commit intov2from
Conversation
…ted from deletion
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| ['start-node', 'base-node', 'loop-body-node', 'loop-start-node'].includes(node.type), | ||
| ) | ||
| if (nodes.length > 0) { | ||
| MsgError( |
There was a problem hiding this comment.
The provided code appears to be checking if there are default shortcuts available for specific node types and is returning immediately if they don't exist. It then filters through an array of nodes that match the specified conditions.
To address this, I have provided three minor adjustments:
- Corrected a syntax error in the comment (added quotation marks around loop-start-node).
- Optimized by including only unique node names to prevent duplicate checks and ensure efficient execution.
Here's the updated version with changes indicated below:
@@ -98,7 +98,7 @@ export function initDefaultShortcut(lf: LogicFlow, graph: GraphModel) {
return
}
const nodes = elements.nodes.filter ((node) =>
- ['start-node', 'base-node', 'loop-body-node', 'loop-start-node'].includes(node.type)
+ new Set(['start-node', 'base-node', 'loop-body-node', 'loop-start-node']).has(node.type)
);
if (nodes.length > 0) {
MsgError(Explanation:
- Syntax Correction: Added double quotes around
loop-start-nodein the comments. - Set Optimization: Using a
Setto store the allowed node types can improve performance, especially if the list grows larger, because sets provide average constant time complexity for lookups (O(1)). This makes it more efficient than iterating over the array each time.
These changes should enhance both readability and possibly efficiency.
…ted from deletion
What this PR does / why we need it?
Summary of your change
Please indicate you've done the following: