Skip to content

fix: generateUpdateMask no period at root#212

Open
brianquinlan wants to merge 1 commit intofirebase:mainfrom
brianquinlan:update_mask
Open

fix: generateUpdateMask no period at root#212
brianquinlan wants to merge 1 commit intofirebase:mainfrom
brianquinlan:update_mask

Conversation

@brianquinlan
Copy link
Copy Markdown
Collaborator

They key change is:

-    final nextPath = root.isEmpty ? '$root.$key' : '$key';
+    final nextPath = root.isEmpty ? key.toString() : '$root.$key';

I was changing the docs for this function at the code above just looked incorrect to me visually. But I don't know what this code is supposed to do so maybe I'm wrong ;-)

I've written unit tests to verify what I think that the code is supposed to do but someone who understands what the intent behind generateUpdateMask needs to verify.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@64bf037). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #212   +/-   ##
=======================================
  Coverage        ?   74.59%           
=======================================
  Files           ?      105           
  Lines           ?     6724           
  Branches        ?        0           
=======================================
  Hits            ?     5016           
  Misses          ?     1708           
  Partials        ?        0           
Flag Coverage Δ
unittests 74.59% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the generateUpdateMask utility function to simplify its logic and improve path generation, while also adding comprehensive unit tests. The reviewer suggested an optimization to the recursive path collection to avoid redundant list iterations and string concatenations.

Comment on lines +31 to 33
for (final mask in maskList) {
updateMask.add('$key.$mask');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation of _generateUpdateMask recursively calls itself and then manually prepends the current key to the results. This results in an O(N^2) string concatenation behavior due to repeated list iteration and string building. It is more efficient to pass the current path down the recursion and collect the final paths directly.

    final maskList = _generateUpdateMask(obj[key], nextPath);
    if (maskList.isNotEmpty) {
      updateMask.addAll(maskList);
    } else {
      updateMask.add(nextPath);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants