mathiasbynens / dotfiles

:wrench: .files, including ~/.macos — sensible hacker defaults for macOS
https://mths.be/dotfiles
MIT License
30.01k stars 8.74k forks source link

`gz()` is inefficient #1042

Open Rudxain opened 1 year ago

Rudxain commented 1 year ago

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

mathiasbynens commented 1 year ago

Mind sending a patch?

Rudxain commented 1 year ago

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)