bito-code-review[bot] commented on PR #40983:
URL: https://github.com/apache/superset/pull/40983#issuecomment-4715344733

   <!-- Bito Reply -->
   The proposed optimization is correct. You can avoid the O(n) `getFromArr` 
scan by checking if `action.queryEditor.id` matches the `unsavedQueryEditor.id` 
first. If they match, you can skip the normalization step entirely, as the ID 
is already resolved. Only perform the `getFromArr` lookup if the IDs do not 
match, which handles the tabViewId restore case.
   
   **superset-frontend/src/SqlLab/reducers/sqlLab.ts**
   ```
   [actions.QUERY_EDITOR_SET_SQL]() {
         const { unsavedQueryEditor } = state;
         const actionId = action.queryEditor!.id!;
         
         // Skip lookup if already matched
         const normalizedId = unsavedQueryEditor?.id === actionId
           ? actionId
           : (getFromArr(state.queryEditors, actionId, 'tabViewId') as 
QueryEditor | undefined)?.id ?? actionId;
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to