`gz()` is inefficient
Rudxain opened this issue · comments
Ricardo Fernández Serrata commented
It uses wc -c
which iterates over every single byte, when counting the size. I know wc
is portable, but I suggest we use an alternative that does a syscall to fetch the size directly from the filesystem
Mathias Bynens commented
Mind sending a patch?
Ricardo Fernández Serrata commented
Mind sending a patch?
Ok, I'll open a PR that uses stat
. I have no idea about its portability, but it seems simple and fast enough.
BTW, I have this
alias sizeof="stat -c '%s'"
In my .aliases
file. It seems the fs
function is more feature-rich, but I like to keep things simple (sometimes)