Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compare buffer bytes directly for faster detection
Previously, in order to detect the type of the file, the buffer was converted to ASCII strings and then compared to hard-coded strings. Now, the bytes of the buffer are compared directly to hard-coded bytes, which is more efficient. name old time/op new time/op delta Calipers/png-304x85 90.9µs ± 3% 85.6µs ± 3% -5.85% (p=0.008 n=5+5) Calipers/png-304x85-buffer 2.14µs ± 8% 1.29µs ± 3% -39.67% (p=0.008 n=5+5)
- Loading branch information