aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorReverend Homer <mk.43.ecko@gmail.com>2018-11-26 16:01:17 +0300
committerRob Landley <rob@landley.net>2018-11-26 12:08:50 -0600
commit9c8d2169ea07d828dbbbabb5fbc90b71f43bd9a3 (patch)
treeae0fa290055cecce3b7546fd1b81ef0cf685f65f /toys
parent7f062f2dcfa5511139476e1aef8db74f49566432 (diff)
downloadtoybox-9c8d2169ea07d828dbbbabb5fbc90b71f43bd9a3.tar.gz
file: small do_regular_file optimization
There are a bunch of if (!memcmp(s+28,...)) lines, let's make them "else if"
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/file.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/toys/posix/file.c b/toys/posix/file.c
index 8d8d5579..7d7bc3eb 100644
--- a/toys/posix/file.c
+++ b/toys/posix/file.c
@@ -302,20 +302,20 @@ static void do_regular_file(int fd, char *name)
xprintf("Ogg data");
// https://wiki.xiph.org/MIMETypesCodecs
if (!memcmp(s+28, "CELT ", 8)) xprintf(", celt audio");
- if (!memcmp(s+28, "CMML ", 8)) xprintf(", cmml text");
- if (!memcmp(s+28, "BBCD\0", 5)) xprintf(", dirac video");
- if (!memcmp(s+28, "\177FLAC", 5)) xprintf(", flac audio");
- if (!memcmp(s+28, "\x8bJNG\r\n\x1a\n", 8)) xprintf(", jng video");
- if (!memcmp(s+28, "\x80kate\0\0\0", 8)) xprintf(", kate text");
- if (!memcmp(s+28, "OggMIDI\0", 8)) xprintf(", midi text");
- if (!memcmp(s+28, "\x8aMNG\r\n\x1a\n", 8)) xprintf(", mng video");
- if (!memcmp(s+28, "OpusHead", 8)) xprintf(", opus audio");
- if (!memcmp(s+28, "PCM ", 8)) xprintf(", pcm audio");
- if (!memcmp(s+28, "\x89PNG\r\n\x1a\n", 8)) xprintf(", png video");
- if (!memcmp(s+28, "Speex ", 8)) xprintf(", speex audio");
- if (!memcmp(s+28, "\x80theora", 7)) xprintf(", theora video");
- if (!memcmp(s+28, "\x01vorbis", 7)) xprintf(", vorbis audio");
- if (!memcmp(s+28, "YUV4MPEG", 8)) xprintf(", yuv4mpeg video");
+ else if (!memcmp(s+28, "CMML ", 8)) xprintf(", cmml text");
+ else if (!memcmp(s+28, "BBCD\0", 5)) xprintf(", dirac video");
+ else if (!memcmp(s+28, "\177FLAC", 5)) xprintf(", flac audio");
+ else if (!memcmp(s+28, "\x8bJNG\r\n\x1a\n", 8)) xprintf(", jng video");
+ else if (!memcmp(s+28, "\x80kate\0\0\0", 8)) xprintf(", kate text");
+ else if (!memcmp(s+28, "OggMIDI\0", 8)) xprintf(", midi text");
+ else if (!memcmp(s+28, "\x8aMNG\r\n\x1a\n", 8)) xprintf(", mng video");
+ else if (!memcmp(s+28, "OpusHead", 8)) xprintf(", opus audio");
+ else if (!memcmp(s+28, "PCM ", 8)) xprintf(", pcm audio");
+ else if (!memcmp(s+28, "\x89PNG\r\n\x1a\n", 8)) xprintf(", png video");
+ else if (!memcmp(s+28, "Speex ", 8)) xprintf(", speex audio");
+ else if (!memcmp(s+28, "\x80theora", 7)) xprintf(", theora video");
+ else if (!memcmp(s+28, "\x01vorbis", 7)) xprintf(", vorbis audio");
+ else if (!memcmp(s+28, "YUV4MPEG", 8)) xprintf(", yuv4mpeg video");
xputc('\n');
} else if (len>32 && !memcmp(s, "RIF", 3) && !memcmp(s+8, "WAVEfmt ", 8)) {
// https://en.wikipedia.org/wiki/WAV