From 3955606c729d28e47fdeabbb8506ec5d57b3bfdd Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Fri, 28 Nov 2008 21:57:06 +0100 Subject: [PATCH] use strrchr instead of a loop --- src/song.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/song.cpp b/src/song.cpp index 7989013e..70035565 100644 --- a/src/song.cpp +++ b/src/song.cpp @@ -58,14 +58,9 @@ Song::Song(mpd_Song *s, bool copy_ptr) : itsSong(s), if (itsSong->file) { - for (size_t i = file_len-1; i < file_len; i--) - { - if (itsSong->file[i] == '/') - { - itsSlash = i; - break; - } - } + char *tmp = strrchr(itsSong->file, '/'); + if (tmp) + itsSlash = tmp-itsSong->file; if (strncmp(itsSong->file, "http://", 7) == 0) isStream = 1; }