aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-12-16 21:20:09 +0100
committerMax Kellermann <max@duempel.org>2008-12-16 21:20:09 +0100
commitb765c62f2f4fdec585e1372765c4c4a076b9154c (patch)
tree019581079c464885126e65890a77d8c5971e6da4
parentd0024c077d94963d86651748888187944441699c (diff)
downloadmpd-b765c62f2f4fdec585e1372765c4c4a076b9154c.tar.gz
mpd-b765c62f2f4fdec585e1372765c4c4a076b9154c.tar.xz
mpd-b765c62f2f4fdec585e1372765c4c4a076b9154c.zip
ls: reimplement getSuffix() with strrchr()
The old getSuffix() code was quite wasteful, and can be replaced completely with strrchr().
Diffstat (limited to '')
-rw-r--r--src/ls.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/ls.c b/src/ls.c
index 60121472d..65692dc1f 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -59,15 +59,9 @@ bool isRemoteUrl(const char *url)
/* suffixes should be ascii only characters */
const char *getSuffix(const char *utf8file)
{
- const char *ret = NULL;
+ const char *dot = strrchr(utf8file, '.');
- while (*utf8file) {
- if (*utf8file == '.')
- ret = utf8file + 1;
- utf8file++;
- }
-
- return ret;
+ return dot != NULL ? dot + 1 : NULL;
}
const struct decoder_plugin *