Skip to content

Remove caching of auto-converted values #303

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

Merged
merged 1 commit into from
Dec 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions Parse/src/main/java/com/parse/ParseObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -3139,18 +3139,13 @@ public Number getNumber(String key) {
* The key to access the value for.
* @return {@code null} if there is no such key or if it is not a {@link JSONArray}.
*/
//TODO (grantland): Do not auto-convert JSONArray and List (v2)
// Calling this on an untouched fetched object will mark the object as dirty due to mutable
// containers and auto List <-> JSONArray conversion, since arrays are converted to List
// by default.
public JSONArray getJSONArray(String key) {
synchronized (mutex) {
checkGetAccess(key);
Object value = estimatedData.get(key);

if (value instanceof List) {
value = PointerOrLocalIdEncoder.get().encode(value);
put(key, value);
}

if (!(value instanceof JSONArray)) {
Expand All @@ -3168,15 +3163,13 @@ public JSONArray getJSONArray(String key) {
* @return {@code null} if there is no such key or if the value can't be converted to a
* {@link List}.
*/
//TODO (grantland): Do not auto-convert JSONArray and List (v2)
public <T> List<T> getList(String key) {
synchronized (mutex) {
Object value = estimatedData.get(key);

if (value instanceof JSONArray) {
ParseDecoder decoder = ParseDecoder.get();
value = decoder.convertJSONArrayToList((JSONArray) value);
put(key, value);
}

if (!(value instanceof List)) {
Expand All @@ -3196,15 +3189,13 @@ public <T> List<T> getList(String key) {
* @return {@code null} if there is no such key or if the value can't be converted to a
* {@link Map}.
*/
//TODO (grantland): Do not auto-convert JSONObject and Map (v2)
public <V> Map<String, V> getMap(String key) {
synchronized (mutex) {
Object value = estimatedData.get(key);

if (value instanceof JSONObject) {
ParseDecoder decoder = ParseDecoder.get();
value = decoder.convertJSONObjectToMap((JSONObject) value);
put(key, value);
}

if (!(value instanceof Map)) {
Expand All @@ -3223,18 +3214,13 @@ public <V> Map<String, V> getMap(String key) {
* The key to access the value for.
* @return {@code null} if there is no such key or if it is not a {@link JSONObject}.
*/
//TODO (grantland): Do not auto-convert JSONObject and Map (v2)
// Calling this on an untouched fetched object will mark the object as dirty due to mutable
// containers and auto Map <-> JSONObject conversion, since maps are converted to Map
// by default.
public JSONObject getJSONObject(String key) {
synchronized (mutex) {
checkGetAccess(key);
Object value = estimatedData.get(key);

if (value instanceof Map) {
value = PointerOrLocalIdEncoder.get().encode(value);
put(key, value);
}

if (!(value instanceof JSONObject)) {
Expand Down