korbit-ai[bot] commented on code in PR #35289:
URL: https://github.com/apache/superset/pull/35289#discussion_r2378906908


##########
superset-frontend/src/features/databases/DatabaseModal/index.tsx:
##########
@@ -310,13 +310,17 @@ export function dbReducer(
         };
       }
       if (action.payload.name === 'schemas_allowed_for_file_upload') {
+        const schemas = (action.payload.value || '').split(',');
+        const hasTrailingComma = (action.payload.value || '').endsWith(',');
+        const filteredSchemas = schemas.filter(schema => schema !== '');

Review Comment:
   ### Redundant string operations in reducer <sub>![category 
Performance](https://img.shields.io/badge/Performance-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The code performs redundant string operations by calling 
`(action.payload.value || '')` three times and executing `.split(',')` followed 
by `.filter()` on the same data.
   
   
   ###### Why this matters
   This creates unnecessary computational overhead and multiple string 
evaluations that could impact performance, especially if this reducer is called 
frequently during user input.
   
   ###### Suggested change ∙ *Feature Preview*
   Cache the string value once and optimize the filtering logic:
   
   ```typescript
   const value = action.payload.value || '';
   const hasTrailingComma = value.endsWith(',');
   const filteredSchemas = value.split(',').filter(schema => schema !== '');
   ```
   
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice 
Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3fe1f356-a007-4d85-8763-e77cb7bff3ba/upvote)
 
[![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3fe1f356-a007-4d85-8763-e77cb7bff3ba?what_not_true=true)
  [![Not in 
Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3fe1f356-a007-4d85-8763-e77cb7bff3ba?what_out_of_scope=true)
 [![Not in coding 
standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3fe1f356-a007-4d85-8763-e77cb7bff3ba?what_not_in_standard=true)
 
[![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3fe1f356-a007-4d85-8763-e77cb7bff3ba)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:33ef7866-3de7-491a-ba13-dff579bf6da1 -->
   
   
   [](33ef7866-3de7-491a-ba13-dff579bf6da1)



-- 
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