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


##########
superset-frontend/src/features/databases/DatabaseModal/index.tsx:
##########
@@ -316,7 +316,11 @@ export function dbReducer(
             ...extraJson,
             schemas_allowed_for_file_upload: (action.payload.value || '')
               .split(',')
-              .filter(schema => schema !== ''),
+              .filter((schema, index, arr) => {
+                const trimmed = schema.trim();
+                if (index === arr.length - 1) return true;
+                return trimmed !== '';
+              }),

Review Comment:
   ### Inefficient Schema Array Filtering <sub>![category 
Performance](https://img.shields.io/badge/Performance-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The filtering method performs unnecessary iterations and string operations 
by checking every element and trimming values that might be discarded.
   
   
   ###### Why this matters
   Inefficient string operations and array traversal can impact performance 
when dealing with large lists of schemas. Each element undergoes a trim() 
operation before knowing if it will be kept.
   
   ###### Suggested change ∙ *Feature Preview*
   Optimize the filtering by using a more efficient approach that only trims 
values when needed:
   ```typescript
   .split(',')
   .map(schema => schema.trim())
   .filter((schema, index, arr) => 
     index === arr.length - 1 || 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/026c80f6-ead1-4a20-a494-eeacebb2d859/upvote)
 
[![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/026c80f6-ead1-4a20-a494-eeacebb2d859?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/026c80f6-ead1-4a20-a494-eeacebb2d859?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/026c80f6-ead1-4a20-a494-eeacebb2d859?what_not_in_standard=true)
 
[![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/026c80f6-ead1-4a20-a494-eeacebb2d859)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:ca2940e9-08ff-4119-bb6c-e3792519ea36 -->
   
   
   [](ca2940e9-08ff-4119-bb6c-e3792519ea36)



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