fix: generateUpdateMask no period at root#212
fix: generateUpdateMask no period at root#212brianquinlan wants to merge 1 commit intofirebase:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #212 +/- ##
=======================================
Coverage ? 74.59%
=======================================
Files ? 105
Lines ? 6724
Branches ? 0
=======================================
Hits ? 5016
Misses ? 1708
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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.
| for (final mask in maskList) { | ||
| updateMask.add('$key.$mask'); | ||
| } |
There was a problem hiding this comment.
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);
}
They key change is:
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
generateUpdateMaskneeds to verify.