Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Untangle ObjectValue and ObjectValueBuilder #2970

Merged
merged 5 commits into from
Apr 23, 2020

Conversation

schmidt-sebastian
Copy link
Contributor

If ObjectValue doesn't depend on ObjectValueBuilder and doesn't directly offer the ability to extract field masks, then we can use ObjectValue without pulling in SortedMap and SortedSet.

If ObjectValue doesn't depend on ObjectValueBuilder and doesn't directly offer the ability to extract field masks, then we can use ObjectValue without pulling in SortedMap and SortedSet.
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 22, 2020

Binary Size Report

Affected SDKs

  • @firebase/firestore

    Type Base (ce07010) Head (506d013) Diff
    browser 248 kB 248 kB -74 B (-0.0%)
    esm2017 194 kB 194 kB -23 B (-0.0%)
    main 489 kB 489 kB -128 B (-0.0%)
    module 246 kB 246 kB -73 B (-0.0%)
  • @firebase/firestore/memory

    Type Base (ce07010) Head (506d013) Diff
    browser 189 kB 189 kB -74 B (-0.0%)
    esm2017 149 kB 149 kB -23 B (-0.0%)
    main 366 kB 366 kB -128 B (-0.0%)
    module 188 kB 188 kB -73 B (-0.0%)
  • firebase

    Type Base (ce07010) Head (506d013) Diff
    firebase-firestore.js 290 kB 290 kB -77 B (-0.0%)
    firebase-firestore.memory.js 232 kB 232 kB -77 B (-0.0%)
    firebase.js 824 kB 824 kB -77 B (-0.0%)

Test Logs

Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

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

LGTM, with one minor suggestion to consider.

/**
* Returns a FieldMask built from all fields in an MapValue.
*/
export function extractFieldMask(value: api.MapValue): FieldMask {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider changing the argument of extractFieldMask() from api.MapValue to ObjectValue. With this change, the call sites become more readable. For example,

extractFieldMask(objValue.proto.mapValue!);

becomes

extractFieldMask(objValue);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was how the original call worked, but it used one level of indirection. The method is called recursively and only the first level uses an ObjectValue. I debated passing in just an api.Value, which would act as a sort of compromise. It however hides the fact that the method only works on a MapValue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh I see. Feel free to disregard this comment then. The original way you implemented it makes sense.

@schmidt-sebastian schmidt-sebastian merged commit 1ae13d1 into master Apr 23, 2020
@firebase firebase locked and limited conversation to collaborators May 24, 2020
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/untangle branch July 9, 2020 17:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants