mirror of
https://github.com/nextcloud/android.git
synced 2024-11-25 22:55:46 +03:00
Avoid JSON deserialization in common, trivial cases
Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
This commit is contained in:
parent
20c22eb448
commit
eae9ff15c7
1 changed files with 17 additions and 5 deletions
|
@ -88,7 +88,8 @@ public class FileDataStorageManager {
|
|||
private static final String EXCEPTION_MSG = "Exception in batch of operations ";
|
||||
|
||||
public static final int ROOT_PARENT_ID = 0;
|
||||
public static final String NULL_STRING = "null";
|
||||
private static final String JSON_NULL_STRING = "null";
|
||||
private static final String JSON_EMPTY_ARRAY = "[]";
|
||||
|
||||
private final ContentResolver contentResolver;
|
||||
private final ContentProviderClient contentProviderClient;
|
||||
|
@ -931,7 +932,10 @@ public class FileDataStorageManager {
|
|||
ocFile.setLockToken(fileEntity.getLockToken());
|
||||
|
||||
String sharees = fileEntity.getSharees();
|
||||
if (sharees == null || NULL_STRING.equals(sharees) || sharees.isEmpty()) {
|
||||
// Surprisingly JSON deserialization causes significant overhead.
|
||||
// Avoid it in common, trivial cases (null/empty).
|
||||
if (sharees == null || sharees.isEmpty() ||
|
||||
JSON_NULL_STRING.equals(sharees) || JSON_EMPTY_ARRAY.equals(sharees)) {
|
||||
ocFile.setSharees(new ArrayList<>());
|
||||
} else {
|
||||
try {
|
||||
|
@ -944,11 +948,19 @@ public class FileDataStorageManager {
|
|||
}
|
||||
|
||||
String metadataSize = fileEntity.getMetadataSize();
|
||||
ImageDimension imageDimension = gson.fromJson(metadataSize, ImageDimension.class);
|
||||
if (imageDimension != null) {
|
||||
ocFile.setImageDimension(imageDimension);
|
||||
// Surprisingly JSON deserialization causes significant overhead.
|
||||
// Avoid it in common, trivial cases (null/empty).
|
||||
if (!(metadataSize == null || metadataSize.isEmpty() || JSON_NULL_STRING.equals(metadataSize))) {
|
||||
ImageDimension imageDimension = gson.fromJson(metadataSize, ImageDimension.class);
|
||||
if (imageDimension != null) {
|
||||
ocFile.setImageDimension(imageDimension);
|
||||
}
|
||||
}
|
||||
|
||||
// Log_OC.d(TAG, "createFileInstance - fileName: " + fileEntity.getPathDecrypted() +
|
||||
// " sharees: -->" + (sharees == null ? "<NULL>" : sharees) + "<--" +
|
||||
// " metadataSize: -->" + (metadataSize == null ? "<NULL>" : metadataSize) + "<--");
|
||||
|
||||
return ocFile;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue