60fb26ab0a
The speed up is achieved by multiple changes: 1) Use list() instead of listFiles() function. The former only returns a String array containing the relative pathnames, and therefore is faster and consumes less memory. 2) The list() function should only be called once. In the previous implementation, the function was called twice (for directories). The first time it was only checked against null and then thrown away. 3) The Strings do not have a "isHidden" property, obviously. However, hidden files can be easily distinguished by checking if the first character is a dot ("."). Performance tests were done in a directory with 12 sub-directories that have about 900 children in total. The old implementation needed about 400-500 ms to list the directory. With the new implementation, only 100ms are needed. |
||
---|---|---|
.. | ||
src/main | ||
.gitignore | ||
build.gradle | ||
proguard-rules.pro |