fontdb
fontdb copied to clipboard
Library uses not optimal is_file implementation
When running my app, I found strange is_file
in flamegraph(look at the right side of flamegraph)
Path.is_file() - get file metadata from disk which is slow and redundant, because DirEntry already read if this is file or not
Entire function load_system_fonts
takes 7.46% time of running app and is_file
0.91%, so changing this code will give free 12% performance boost.
The only thing that needs to be changed is to change from - https://github.com/RazrFalcon/fontdb/blob/c3274d016cad92fac744d76a91e4554fe51c5745/src/lib.rs#L315C2-L318
let path = entry.path();
if path.is_file() {
} else if path.is_dir() {
}
into
let file_type = entry.file_type();
if file_type.is_file() {
} else if file_type.is_dir() {
}
Interesting. Patches are welcome.
Fixed by https://github.com/RazrFalcon/fontdb/pull/65