Merge pull request #75 from rsnitsch/improve_get_children_performance

Speed up directory listing by factor 4-5 by improving getChildren function
This commit is contained in:
Tibor Kaputa 2017-07-09 09:43:46 +02:00 committed by GitHub
commit 2c4ef37f15
1 changed files with 4 additions and 3 deletions

View File

@ -162,14 +162,15 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener {
} }
private fun getChildren(file: File): Int { private fun getChildren(file: File): Int {
if (file.listFiles() == null) var fileList = file.list()
if (fileList == null)
return 0 return 0
if (file.isDirectory) { if (file.isDirectory) {
return if (mShowHidden) { return if (mShowHidden) {
file.listFiles()?.size ?: 0 fileList.size
} else { } else {
file.listFiles { file -> !file.isHidden }?.size ?: 0 fileList.count { fileName -> fileName[0] != '.' }
} }
} }
return 0 return 0