Skip to content

Commit 73d2fa3

Browse files
committed
Only perform expensive overlay application when overlay is NOT empty.
1 parent 82b4723 commit 73d2fa3

File tree

1 file changed

+7
-5
lines changed
  • firebase-firestore/src/main/java/com/google/firebase/firestore/model

1 file changed

+7
-5
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/model/ObjectValue.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,13 @@ private static Value extractNestedValue(Value value, FieldPath fieldPath) {
122122
* invocations are based on this memoized result.
123123
*/
124124
private Value buildProto() {
125-
synchronized (overlayMap) {
126-
MapValue mergedResult = applyOverlay(FieldPath.EMPTY_PATH, overlayMap);
127-
if (mergedResult != null) {
128-
partialValue = Value.newBuilder().setMapValue(mergedResult).build();
129-
overlayMap.clear();
125+
if (!overlayMap.isEmpty()) {
126+
synchronized (overlayMap) {
127+
MapValue mergedResult = applyOverlay(FieldPath.EMPTY_PATH, overlayMap);
128+
if (mergedResult != null) {
129+
partialValue = Value.newBuilder().setMapValue(mergedResult).build();
130+
overlayMap.clear();
131+
}
130132
}
131133
}
132134
return partialValue;

0 commit comments

Comments
 (0)