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 ;
@@ -307,7 +306,6 @@ public String toString() {
307
306
// Cached State
308
307
private final Map <String , Object > estimatedData ;
309
308
private final Map <String , Boolean > dataAvailability ;
310
- private final Map <Object , ParseJSONCacheItem > hashedObjects ; // For mutable containers
311
309
312
310
private String localId ;
313
311
private final ParseMulticastDelegate <ParseObject > saveEvent = new ParseMulticastDelegate <>();
@@ -384,7 +382,6 @@ public ParseObject(String theClassName) {
384
382
operationSetQueue = new LinkedList <>();
385
383
operationSetQueue .add (new ParseOperationSet ());
386
384
estimatedData = new HashMap <>();
387
- hashedObjects = new IdentityHashMap <>();
388
385
dataAvailability = new HashMap <>();
389
386
390
387
State .Init <?> builder = newStateBuilder (theClassName );
@@ -617,16 +614,6 @@ public Void then(Task<Void> task) throws Exception {
617
614
}
618
615
}
619
616
620
- private void addToHashedObjects (Object object ) {
621
- synchronized (mutex ) {
622
- try {
623
- hashedObjects .put (object , new ParseJSONCacheItem (object ));
624
- } catch (JSONException e ) {
625
- throw new IllegalArgumentException ("Couldn't serialize container value to JSON." );
626
- }
627
- }
628
- }
629
-
630
617
/**
631
618
* Converts a {@code ParseObject.State} to a {@code ParseObject}.
632
619
*
@@ -755,7 +742,6 @@ private void setState(State newState, boolean notifyIfObjectIdChanges) {
755
742
756
743
rebuildEstimatedData ();
757
744
rebuildDataAvailability ();
758
- checkpointAllMutableContainers ();
759
745
}
760
746
}
761
747
@@ -844,7 +830,6 @@ public Set<String> keySet() {
844
830
currentOperations ().remove (key );
845
831
rebuildEstimatedData ();
846
832
rebuildDataAvailability ();
847
- checkpointAllMutableContainers ();
848
833
}
849
834
}
850
835
@@ -857,7 +842,6 @@ public Set<String> keySet() {
857
842
currentOperations ().clear ();
858
843
rebuildEstimatedData ();
859
844
rebuildDataAvailability ();
860
- checkpointAllMutableContainers ();
861
845
}
862
846
}
863
847
@@ -1031,8 +1015,6 @@ protected boolean visit(Object object) {
1031
1015
1032
1016
/* package */ JSONObject toRest (
1033
1017
State state , List <ParseOperationSet > operationSetQueue , ParseEncoder objectEncoder ) {
1034
- checkForChangesToMutableContainers ();
1035
-
1036
1018
// Public data goes in dataJSON; special fields go in objectJSON.
1037
1019
JSONObject json = new JSONObject ();
1038
1020
@@ -1182,7 +1164,6 @@ public boolean isDirty() {
1182
1164
1183
1165
/* package */ boolean isDirty (boolean considerChildren ) {
1184
1166
synchronized (mutex ) {
1185
- checkForChangesToMutableContainers ();
1186
1167
return (isDeleted || getObjectId () == null || hasChanges () || (considerChildren && hasDirtyChildren ()));
1187
1168
}
1188
1169
}
@@ -1217,80 +1198,6 @@ public boolean isDirty(String key) {
1217
1198
}
1218
1199
}
1219
1200
1220
- //region Mutable Containers
1221
-
1222
- /* package */ boolean isContainerObject (String key , Object object ) {
1223
- return (object instanceof JSONObject || object instanceof JSONArray
1224
- || object instanceof Map || object instanceof List
1225
- || object instanceof ParseACL || object instanceof ParseGeoPoint );
1226
- }
1227
-
1228
- /**
1229
- * Updates the JSON cache value for all of the values in estimatedData.
1230
- */
1231
- private void checkpointAllMutableContainers () {
1232
- synchronized (mutex ) {
1233
- for (Map .Entry <String , Object > entry : estimatedData .entrySet ()) {
1234
- checkpointMutableContainer (entry .getKey (), entry .getValue ());
1235
- }
1236
- }
1237
- }
1238
-
1239
- /**
1240
- * Updates the JSON cache value for the given object.
1241
- */
1242
- private void checkpointMutableContainer (String key , Object object ) {
1243
- synchronized (mutex ) {
1244
- if (isContainerObject (key , object )) {
1245
- addToHashedObjects (object );
1246
- }
1247
- }
1248
- }
1249
-
1250
- /**
1251
- * Inspects to see if a given mutable container owned by this object has been mutated, and treats
1252
- * any mutation as a new {@link #put(String, Object)} call.
1253
- */
1254
- private void checkForChangesToMutableContainer (String key , Object object ) {
1255
- synchronized (mutex ) {
1256
- if (isContainerObject (key , object )) {
1257
- ParseJSONCacheItem oldCacheItem = hashedObjects .get (object );
1258
- if (oldCacheItem == null ) {
1259
- throw new IllegalArgumentException (
1260
- "ParseObject contains container item that isn't cached." );
1261
- } else {
1262
- ParseJSONCacheItem newCacheItem ;
1263
- try {
1264
- newCacheItem = new ParseJSONCacheItem (object );
1265
- } catch (JSONException e ) {
1266
- throw new RuntimeException (e );
1267
- }
1268
- if (!oldCacheItem .equals (newCacheItem )) {
1269
- // A mutable container changed out from under us. Treat it as a set operation.
1270
- performOperation (key , new ParseSetOperation (object ));
1271
- }
1272
- }
1273
- } else {
1274
- hashedObjects .remove (object );
1275
- }
1276
- }
1277
- }
1278
-
1279
- /**
1280
- * Inspects to see if any mutable container owned by this object has been mutated, and treats any
1281
- * mutation as a new {@link #put(String, Object)} call.
1282
- */
1283
- /* package */ void checkForChangesToMutableContainers () {
1284
- synchronized (mutex ) {
1285
- for (String key : estimatedData .keySet ()) {
1286
- checkForChangesToMutableContainer (key , estimatedData .get (key ));
1287
- }
1288
- hashedObjects .keySet ().retainAll (estimatedData .values ());
1289
- }
1290
- }
1291
-
1292
- //endregion
1293
-
1294
1201
/**
1295
1202
* Accessor to the object id. An object id is assigned as soon as an object is saved to the
1296
1203
* server. The combination of a className and an objectId uniquely identifies an object in your
@@ -2989,7 +2896,6 @@ private void rebuildDataAvailability() {
2989
2896
ParseFieldOperation newOperation = operation .mergeWithPrevious (oldOperation );
2990
2897
currentOperations ().put (key , newOperation );
2991
2898
2992
- checkpointMutableContainer (key , newValue );
2993
2899
dataAvailability .put (key , Boolean .TRUE );
2994
2900
}
2995
2901
}
@@ -3518,7 +3424,6 @@ private ParseACL getACL(boolean mayCopy) {
3518
3424
if (mayCopy && ((ParseACL ) acl ).isShared ()) {
3519
3425
ParseACL copy = ((ParseACL ) acl ).copy ();
3520
3426
estimatedData .put (KEY_ACL , copy );
3521
- addToHashedObjects (copy );
3522
3427
return copy ;
3523
3428
}
3524
3429
return (ParseACL ) acl ;
0 commit comments