Skip to content

Optimize and cleanup CacheFile

Use QHash instead of QMap to store mappings created for the file. This changes the complexity of CacheFile::map from O(log N), where N is the number of created mappings, to roughly O(1).

Reduce code duplication in CacheFile::map, as the two branches of aligned and unaligned file offset were nearly identical.

Cache page size on POSIX systems to avoid calling sysconf every time in CacheFile::map.

Remove CacheFile::Entry::diff member since it was not used anywhere. If needed, this value can be inferred from the difference between the key of the mappings hash table and CacheFile::Entry::ptr. Also, reordered some data members to reduce size overhead from padding.

Avoid duplicate mapping lookups in CacheFile::unmap.

Avoid using errno in complex expressions, since errno is volatile and may be clobbered. Always read errno as close to the failed syscall as possible and use the read value in formatting expressions.

Merge request reports

Loading