You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Optimize DirAccessUnix::get_next() for some file systems
On some file systems, like ext4 on Linux, readdir() gives enough information to determine the entry type in order to avoid doing a stat() system call. Use this information and call stat() only if necessary.
This commit is contained in:
@@ -136,11 +136,12 @@ String DirAccessUnix::get_next() {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String fname = fix_unicode_name(entry->d_name);
|
||||||
|
|
||||||
|
if (entry->d_type == DT_UNKNOWN) {
|
||||||
//typedef struct stat Stat;
|
//typedef struct stat Stat;
|
||||||
struct stat flags;
|
struct stat flags;
|
||||||
|
|
||||||
String fname = fix_unicode_name(entry->d_name);
|
|
||||||
|
|
||||||
String f = current_dir.plus_file(fname);
|
String f = current_dir.plus_file(fname);
|
||||||
|
|
||||||
if (stat(f.utf8().get_data(), &flags) == 0) {
|
if (stat(f.utf8().get_data(), &flags) == 0) {
|
||||||
@@ -158,6 +159,9 @@ String DirAccessUnix::get_next() {
|
|||||||
|
|
||||||
_cisdir = false;
|
_cisdir = false;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
_cisdir = (entry->d_type == DT_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
_cishidden = (fname != "." && fname != ".." && fname.begins_with("."));
|
_cishidden = (fname != "." && fname != ".." && fname.begins_with("."));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user