Copilot commented on code in PR #40983:
URL: https://github.com/apache/superset/pull/40983#discussion_r3418371922
##########
superset-frontend/src/SqlLab/reducers/sqlLab.ts:
##########
@@ -604,8 +604,17 @@ export default function sqlLabReducer(
},
[actions.QUERY_EDITOR_SET_SQL]() {
const { unsavedQueryEditor } = state;
+ // Normalize tabViewId to client-side id (same pattern as START_QUERY)
+ const queryEditorByTabId = getFromArr(
+ state.queryEditors,
+ action.queryEditor!.id!,
+ 'tabViewId',
+ );
+ const normalizedId =
+ (queryEditorByTabId as QueryEditor | undefined)?.id ??
+ action.queryEditor!.id!;
Review Comment:
`QUERY_EDITOR_SET_SQL` is dispatched on every SQL edit (keystroke). The
added `getFromArr(state.queryEditors, ..., 'tabViewId')` scan runs even in the
common case where `action.queryEditor.id` is already the client-side id, adding
avoidable O(n) work in a hot reducer path. You can skip the lookup when the
action id already matches the active unsaved editor id, and only normalize when
it doesn’t match (i.e. the tabViewId restore path).
--
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]