by rasz · 7y ago · 0 comments
Every directory has entries "." and "..", which we aren't interested in. We filter them out with a helper function Dots().
bool Dots(const char* s) { return s[0] == '.' && (!s[1] || (s[1] == '.' && !s[2])); }
why would you iterate over every single file entry? both . .. entries will land at one end of sorted list anyway.From the article: Digging into the source code of std::sort() we can see that it uses Insertion Sort for short collections. Our 32-element vector falls under the threshold. Insertion Sort makes O(N^2) comparisons
> arent . .. entries always at the beginning of the list?
No.