21
21
import java .util .Date ;
22
22
import java .util .HashMap ;
23
23
import java .util .HashSet ;
24
- import java .util .IdentityHashMap ;
25
24
import java .util .Iterator ;
26
25
import java .util .LinkedList ;
27
26
import java .util .List ;
@@ -306,7 +305,6 @@ public String toString() {
306
305
307
306
// Cached State
308
307
private final Map <String , Object > estimatedData ;
309
- private final Map <Object , ParseJSONCacheItem > hashedObjects ; // For mutable containers
310
308
311
309
private String localId ;
312
310
private final ParseMulticastDelegate <ParseObject > saveEvent = new ParseMulticastDelegate <>();
@@ -383,7 +381,6 @@ public ParseObject(String theClassName) {
383
381
operationSetQueue = new LinkedList <>();
384
382
operationSetQueue .add (new ParseOperationSet ());
385
383
estimatedData = new HashMap <>();
386
- hashedObjects = new IdentityHashMap <>();
387
384
388
385
State .Init <?> builder = newStateBuilder (theClassName );
389
386
// When called from new, assume hasData for the whole object is true.
@@ -615,16 +612,6 @@ public Void then(Task<Void> task) throws Exception {
615
612
}
616
613
}
617
614
618
- private void addToHashedObjects (Object object ) {
619
- synchronized (mutex ) {
620
- try {
621
- hashedObjects .put (object , new ParseJSONCacheItem (object ));
622
- } catch (JSONException e ) {
623
- throw new IllegalArgumentException ("Couldn't serialize container value to JSON." );
624
- }
625
- }
626
- }
627
-
628
615
/**
629
616
* Converts a {@code ParseObject.State} to a {@code ParseObject}.
630
617
*
@@ -752,7 +739,6 @@ private void setState(State newState, boolean notifyIfObjectIdChanges) {
752
739
}
753
740
754
741
rebuildEstimatedData ();
755
- checkpointAllMutableContainers ();
756
742
}
757
743
}
758
744
@@ -840,7 +826,6 @@ public Set<String> keySet() {
840
826
synchronized (mutex ) {
841
827
currentOperations ().remove (key );
842
828
rebuildEstimatedData ();
843
- checkpointAllMutableContainers ();
844
829
}
845
830
}
846
831
@@ -852,7 +837,6 @@ public Set<String> keySet() {
852
837
synchronized (mutex ) {
853
838
currentOperations ().clear ();
854
839
rebuildEstimatedData ();
855
- checkpointAllMutableContainers ();
856
840
}
857
841
}
858
842
@@ -1026,8 +1010,6 @@ protected boolean visit(Object object) {
1026
1010
1027
1011
/* package */ JSONObject toRest (
1028
1012
State state , List <ParseOperationSet > operationSetQueue , ParseEncoder objectEncoder ) {
1029
- checkForChangesToMutableContainers ();
1030
-
1031
1013
// Public data goes in dataJSON; special fields go in objectJSON.
1032
1014
JSONObject json = new JSONObject ();
1033
1015
@@ -1177,7 +1159,6 @@ public boolean isDirty() {
1177
1159
1178
1160
/* package */ boolean isDirty (boolean considerChildren ) {
1179
1161
synchronized (mutex ) {
1180
- checkForChangesToMutableContainers ();
1181
1162
return (isDeleted || getObjectId () == null || hasChanges () || (considerChildren && hasDirtyChildren ()));
1182
1163
}
1183
1164
}
@@ -1212,80 +1193,6 @@ public boolean isDirty(String key) {
1212
1193
}
1213
1194
}
1214
1195
1215
- //region Mutable Containers
1216
-
1217
- /* package */ boolean isContainerObject (String key , Object object ) {
1218
- return (object instanceof JSONObject || object instanceof JSONArray
1219
- || object instanceof Map || object instanceof List
1220
- || object instanceof ParseACL || object instanceof ParseGeoPoint );
1221
- }
1222
-
1223
- /**
1224
- * Updates the JSON cache value for all of the values in estimatedData.
1225
- */
1226
- private void checkpointAllMutableContainers () {
1227
- synchronized (mutex ) {
1228
- for (Map .Entry <String , Object > entry : estimatedData .entrySet ()) {
1229
- checkpointMutableContainer (entry .getKey (), entry .getValue ());
1230
- }
1231
- }
1232
- }
1233
-
1234
- /**
1235
- * Updates the JSON cache value for the given object.
1236
- */
1237
- private void checkpointMutableContainer (String key , Object object ) {
1238
- synchronized (mutex ) {
1239
- if (isContainerObject (key , object )) {
1240
- addToHashedObjects (object );
1241
- }
1242
- }
1243
- }
1244
-
1245
- /**
1246
- * Inspects to see if a given mutable container owned by this object has been mutated, and treats
1247
- * any mutation as a new {@link #put(String, Object)} call.
1248
- */
1249
- private void checkForChangesToMutableContainer (String key , Object object ) {
1250
- synchronized (mutex ) {
1251
- if (isContainerObject (key , object )) {
1252
- ParseJSONCacheItem oldCacheItem = hashedObjects .get (object );
1253
- if (oldCacheItem == null ) {
1254
- throw new IllegalArgumentException (
1255
- "ParseObject contains container item that isn't cached." );
1256
- } else {
1257
- ParseJSONCacheItem newCacheItem ;
1258
- try {
1259
- newCacheItem = new ParseJSONCacheItem (object );
1260
- } catch (JSONException e ) {
1261
- throw new RuntimeException (e );
1262
- }
1263
- if (!oldCacheItem .equals (newCacheItem )) {
1264
- // A mutable container changed out from under us. Treat it as a set operation.
1265
- performOperation (key , new ParseSetOperation (object ));
1266
- }
1267
- }
1268
- } else {
1269
- hashedObjects .remove (object );
1270
- }
1271
- }
1272
- }
1273
-
1274
- /**
1275
- * Inspects to see if any mutable container owned by this object has been mutated, and treats any
1276
- * mutation as a new {@link #put(String, Object)} call.
1277
- */
1278
- /* package */ void checkForChangesToMutableContainers () {
1279
- synchronized (mutex ) {
1280
- for (String key : estimatedData .keySet ()) {
1281
- checkForChangesToMutableContainer (key , estimatedData .get (key ));
1282
- }
1283
- hashedObjects .keySet ().retainAll (estimatedData .values ());
1284
- }
1285
- }
1286
-
1287
- //endregion
1288
-
1289
1196
/**
1290
1197
* Accessor to the object id. An object id is assigned as soon as an object is saved to the
1291
1198
* server. The combination of a className and an objectId uniquely identifies an object in your
@@ -2971,8 +2878,6 @@ private void rebuildEstimatedData() {
2971
2878
ParseFieldOperation oldOperation = currentOperations ().get (key );
2972
2879
ParseFieldOperation newOperation = operation .mergeWithPrevious (oldOperation );
2973
2880
currentOperations ().put (key , newOperation );
2974
-
2975
- checkpointMutableContainer (key , newValue );
2976
2881
}
2977
2882
}
2978
2883
@@ -3500,7 +3405,6 @@ private ParseACL getACL(boolean mayCopy) {
3500
3405
if (mayCopy && ((ParseACL ) acl ).isShared ()) {
3501
3406
ParseACL copy = ((ParseACL ) acl ).copy ();
3502
3407
estimatedData .put (KEY_ACL , copy );
3503
- addToHashedObjects (copy );
3504
3408
return copy ;
3505
3409
}
3506
3410
return (ParseACL ) acl ;
0 commit comments