2121import java .util .Date ;
2222import java .util .HashMap ;
2323import java .util .HashSet ;
24- import java .util .IdentityHashMap ;
2524import java .util .Iterator ;
2625import java .util .LinkedList ;
2726import java .util .List ;
@@ -306,7 +305,6 @@ public String toString() {
306305
307306 // Cached State
308307 private final Map <String , Object > estimatedData ;
309- private final Map <Object , ParseJSONCacheItem > hashedObjects ; // For mutable containers
310308
311309 private String localId ;
312310 private final ParseMulticastDelegate <ParseObject > saveEvent = new ParseMulticastDelegate <>();
@@ -383,7 +381,6 @@ public ParseObject(String theClassName) {
383381 operationSetQueue = new LinkedList <>();
384382 operationSetQueue .add (new ParseOperationSet ());
385383 estimatedData = new HashMap <>();
386- hashedObjects = new IdentityHashMap <>();
387384
388385 State .Init <?> builder = newStateBuilder (theClassName );
389386 // When called from new, assume hasData for the whole object is true.
@@ -615,16 +612,6 @@ public Void then(Task<Void> task) throws Exception {
615612 }
616613 }
617614
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-
628615 /**
629616 * Converts a {@code ParseObject.State} to a {@code ParseObject}.
630617 *
@@ -752,7 +739,6 @@ private void setState(State newState, boolean notifyIfObjectIdChanges) {
752739 }
753740
754741 rebuildEstimatedData ();
755- checkpointAllMutableContainers ();
756742 }
757743 }
758744
@@ -847,7 +833,6 @@ public void revert(String key) {
847833 if (isDirty (key )) {
848834 currentOperations ().remove (key );
849835 rebuildEstimatedData ();
850- checkpointAllMutableContainers ();
851836 }
852837 }
853838 }
@@ -861,7 +846,6 @@ public void revert() {
861846 if (isDirty ()) {
862847 currentOperations ().clear ();
863848 rebuildEstimatedData ();
864- checkpointAllMutableContainers ();
865849 }
866850 }
867851 }
@@ -1036,8 +1020,6 @@ protected boolean visit(Object object) {
10361020
10371021 /* package */ JSONObject toRest (
10381022 State state , List <ParseOperationSet > operationSetQueue , ParseEncoder objectEncoder ) {
1039- checkForChangesToMutableContainers ();
1040-
10411023 // Public data goes in dataJSON; special fields go in objectJSON.
10421024 JSONObject json = new JSONObject ();
10431025
@@ -1187,7 +1169,6 @@ public boolean isDirty() {
11871169
11881170 /* package */ boolean isDirty (boolean considerChildren ) {
11891171 synchronized (mutex ) {
1190- checkForChangesToMutableContainers ();
11911172 return (isDeleted || getObjectId () == null || hasChanges () || (considerChildren && hasDirtyChildren ()));
11921173 }
11931174 }
@@ -1222,80 +1203,6 @@ public boolean isDirty(String key) {
12221203 }
12231204 }
12241205
1225- //region Mutable Containers
1226-
1227- /* package */ boolean isContainerObject (String key , Object object ) {
1228- return (object instanceof JSONObject || object instanceof JSONArray
1229- || object instanceof Map || object instanceof List
1230- || object instanceof ParseACL || object instanceof ParseGeoPoint );
1231- }
1232-
1233- /**
1234- * Updates the JSON cache value for all of the values in estimatedData.
1235- */
1236- private void checkpointAllMutableContainers () {
1237- synchronized (mutex ) {
1238- for (Map .Entry <String , Object > entry : estimatedData .entrySet ()) {
1239- checkpointMutableContainer (entry .getKey (), entry .getValue ());
1240- }
1241- }
1242- }
1243-
1244- /**
1245- * Updates the JSON cache value for the given object.
1246- */
1247- private void checkpointMutableContainer (String key , Object object ) {
1248- synchronized (mutex ) {
1249- if (isContainerObject (key , object )) {
1250- addToHashedObjects (object );
1251- }
1252- }
1253- }
1254-
1255- /**
1256- * Inspects to see if a given mutable container owned by this object has been mutated, and treats
1257- * any mutation as a new {@link #put(String, Object)} call.
1258- */
1259- private void checkForChangesToMutableContainer (String key , Object object ) {
1260- synchronized (mutex ) {
1261- if (isContainerObject (key , object )) {
1262- ParseJSONCacheItem oldCacheItem = hashedObjects .get (object );
1263- if (oldCacheItem == null ) {
1264- throw new IllegalArgumentException (
1265- "ParseObject contains container item that isn't cached." );
1266- } else {
1267- ParseJSONCacheItem newCacheItem ;
1268- try {
1269- newCacheItem = new ParseJSONCacheItem (object );
1270- } catch (JSONException e ) {
1271- throw new RuntimeException (e );
1272- }
1273- if (!oldCacheItem .equals (newCacheItem )) {
1274- // A mutable container changed out from under us. Treat it as a set operation.
1275- performOperation (key , new ParseSetOperation (object ));
1276- }
1277- }
1278- } else {
1279- hashedObjects .remove (object );
1280- }
1281- }
1282- }
1283-
1284- /**
1285- * Inspects to see if any mutable container owned by this object has been mutated, and treats any
1286- * mutation as a new {@link #put(String, Object)} call.
1287- */
1288- /* package */ void checkForChangesToMutableContainers () {
1289- synchronized (mutex ) {
1290- for (String key : estimatedData .keySet ()) {
1291- checkForChangesToMutableContainer (key , estimatedData .get (key ));
1292- }
1293- hashedObjects .keySet ().retainAll (estimatedData .values ());
1294- }
1295- }
1296-
1297- //endregion
1298-
12991206 /**
13001207 * Accessor to the object id. An object id is assigned as soon as an object is saved to the
13011208 * server. The combination of a className and an objectId uniquely identifies an object in your
@@ -2983,8 +2890,6 @@ private void rebuildEstimatedData() {
29832890 ParseFieldOperation oldOperation = currentOperations ().get (key );
29842891 ParseFieldOperation newOperation = operation .mergeWithPrevious (oldOperation );
29852892 currentOperations ().put (key , newOperation );
2986-
2987- checkpointMutableContainer (key , newValue );
29882893 }
29892894 }
29902895
@@ -3512,7 +3417,6 @@ private ParseACL getACL(boolean mayCopy) {
35123417 if (mayCopy && ((ParseACL ) acl ).isShared ()) {
35133418 ParseACL copy = ((ParseACL ) acl ).copy ();
35143419 estimatedData .put (KEY_ACL , copy );
3515- addToHashedObjects (copy );
35163420 return copy ;
35173421 }
35183422 return (ParseACL ) acl ;
0 commit comments