mathiasbynens / dotfiles

:wrench: .files, including ~/.macos — sensible hacker defaults for macOS

Home Page:https://mths.be/dotfiles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`gz()` is inefficient

Rudxain opened this issue · comments

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

Mind sending a patch?

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)