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


##########
superset-frontend/src/components/ListView/utils.ts:
##########
@@ -48,15 +48,22 @@ import {
 // Define custom RisonParam for proper encoding/decoding; note that
 // %, &, +, and # must be encoded to avoid breaking the url
 const RisonParam: QueryParamConfig<string, any> = {
-  encode: (data?: any | null) =>
-    data === undefined
-      ? undefined
-      : rison
-          .encode(data)
-          .replace(/%/g, '%25')
-          .replace(/&/g, '%26')
-          .replace(/\+/g, '%2B')
-          .replace(/#/g, '%23'),
+  encode: (data?: any | null) => {
+    if (data === undefined || data === null) return undefined;
+
+    const cleanData = JSON.parse(
+      JSON.stringify(data, (key, value) =>
+        value === undefined ? null : value,
+      ),
+    );

Review Comment:
   ### Inefficient Deep Clone Operation <sub>![category 
Performance](https://img.shields.io/badge/Performance-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   Using JSON.parse(JSON.stringify()) for object cleanup creates unnecessary 
deep cloning overhead.
   
   
   ###### Why this matters
   This operation requires serializing and deserializing the entire object, 
which is computationally expensive, especially for large objects. It causes 
memory allocation for intermediate string representation.
   
   ###### Suggested change ∙ *Feature Preview*
   Replace with a more efficient object traversal or use a dedicated deep clone 
function like lodash's cloneDeep if needed. For simple undefined-to-null 
conversion, consider a recursive function:
   ```typescript
   const cleanUndefined = (obj: any): any => {
     if (typeof obj !== 'object' || obj === null) return obj;
     if (Array.isArray(obj)) return obj.map(cleanUndefined);
     return Object.fromEntries(
       Object.entries(obj).map(([k, v]) => [k, v === undefined ? null : 
cleanUndefined(v)])
     );
   };
   ```
   
   
   ###### 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/413b0080-1012-4b97-b671-425df7235e98/upvote)
 
[![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/413b0080-1012-4b97-b671-425df7235e98?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/413b0080-1012-4b97-b671-425df7235e98?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/413b0080-1012-4b97-b671-425df7235e98?what_not_in_standard=true)
 
[![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/413b0080-1012-4b97-b671-425df7235e98)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:a00a7dc0-cfd0-4d82-a109-0f0088b1122f -->
   
   
   [](a00a7dc0-cfd0-4d82-a109-0f0088b1122f)



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