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


##########
superset-frontend/packages/superset-ui-core/src/components/Icons/BaseIcon.tsx:
##########
@@ -22,7 +22,7 @@ import { AntdIconType, BaseIconProps, CustomIconType, 
IconType } from './types';
 
 const genAriaLabel = (fileName: string) => {
   const name = fileName.replace(/_/g, '-'); // Replace underscores with dashes
-  const words = name.split(/(?=[A-Z])/); // Split at uppercase letters
+  const words = name.split(/(?=[A-Z])/).filter(word => word.length > 0); // 
Split at uppercase letters and filter out empty strings

Review Comment:
   ### Unnecessary Array Iteration in Aria Label Generation <sub>![category 
Performance](https://img.shields.io/badge/Performance-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The genAriaLabel function performs unnecessary array iteration with filter() 
when the split operation could be optimized to avoid creating empty strings.
   
   
   ###### Why this matters
   Additional array iteration adds processing overhead, especially when this 
function is called frequently for multiple icons on a page.
   
   ###### Suggested change ∙ *Feature Preview*
   Modify the split regex to prevent empty strings in the first place rather 
than filtering them out afterward:
   ```typescript
   const words = name.split(/(?<=[a-z])(?=[A-Z])/);
   ```
   
   
   ###### 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/a1157fb3-c716-4d91-991e-c4ae829cf0d7/upvote)
 
[![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/a1157fb3-c716-4d91-991e-c4ae829cf0d7?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/a1157fb3-c716-4d91-991e-c4ae829cf0d7?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/a1157fb3-c716-4d91-991e-c4ae829cf0d7?what_not_in_standard=true)
 
[![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/a1157fb3-c716-4d91-991e-c4ae829cf0d7)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:f0b8c2b5-e39d-449f-961e-cf69ad98dcb9 -->
   
   
   [](f0b8c2b5-e39d-449f-961e-cf69ad98dcb9)



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