Skip to content

Commit

Permalink
cache StorageFile getName (speeds up getting app backups about 20x in…
Browse files Browse the repository at this point in the history
… current implementation)
  • Loading branch information
hg42 authored and Tiefkuehlpizze committed Sep 26, 2020
1 parent ba609d0 commit 0679aaa
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class StorageFile {
private final StorageFile parent;
private final Context context;
private Uri uri;
private String name;

protected StorageFile(@Nullable StorageFile parent, Context context, Uri uri) {
this.parent = parent;
Expand Down Expand Up @@ -130,7 +131,9 @@ public Uri getUri() {
}

public String getName() {
return DocumentContractApi.getName(this.context, this.uri);
if(this.name == null)
this.name = DocumentContractApi.getName(this.context, this.uri);
return this.name;
}

public StorageFile getParentFile() {
Expand Down

0 comments on commit 0679aaa

Please sign in to comment.