[grilo-plugins] plugins: Prefer g_str_has_prefix() over strstr
- From: Mathias Hasselmann <hasselmm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] plugins: Prefer g_str_has_prefix() over strstr
- Date: Tue, 10 Jul 2012 08:31:50 +0000 (UTC)
commit b92c70db1f6fa02e4471247fcf33da5f8eeb3ade
Author: Mathias Hasselmann <mathias openismus com>
Date: Tue Jul 10 10:25:12 2012 +0200
plugins: Prefer g_str_has_prefix() over strstr
Most of the tested strings should short. Still there is no need to look
for prefixes in the middle of those string.
src/media/bookmarks/grl-bookmarks.c | 4 ++--
src/media/filesystem/grl-filesystem.c | 6 +++---
src/media/podcasts/grl-podcasts.c | 4 ++--
src/media/youtube/grl-youtube.c | 2 +-
4 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/media/bookmarks/grl-bookmarks.c b/src/media/bookmarks/grl-bookmarks.c
index 80dac89..f0ed9f2 100644
--- a/src/media/bookmarks/grl-bookmarks.c
+++ b/src/media/bookmarks/grl-bookmarks.c
@@ -337,13 +337,13 @@ grl_bookmarks_source_finalize (GObject *object)
static gboolean
mime_is_video (const gchar *mime)
{
- return mime && strstr (mime, "video") != NULL;
+ return mime && g_str_has_prefix (mime, "video/") != NULL;
}
static gboolean
mime_is_audio (const gchar *mime)
{
- return mime && strstr (mime, "audio") != NULL;
+ return mime && g_str_has_prefix (mime, "audio/") != NULL;
}
static GrlMedia *
diff --git a/src/media/filesystem/grl-filesystem.c b/src/media/filesystem/grl-filesystem.c
index c364519..5e524c1 100644
--- a/src/media/filesystem/grl-filesystem.c
+++ b/src/media/filesystem/grl-filesystem.c
@@ -258,19 +258,19 @@ static void cancel_monitors (GrlFilesystemSource *fs_source);
static gboolean
mime_is_video (const gchar *mime)
{
- return strstr (mime, "video") != NULL;
+ return g_str_has_prefix (mime, "video/") != NULL;
}
static gboolean
mime_is_audio (const gchar *mime)
{
- return strstr (mime, "audio") != NULL;
+ return g_str_has_prefix (mime, "audio/") != NULL;
}
static gboolean
mime_is_image (const gchar *mime)
{
- return strstr (mime, "image") != NULL;
+ return g_str_has_prefix (mime, "image/") != NULL;
}
static gboolean
diff --git a/src/media/podcasts/grl-podcasts.c b/src/media/podcasts/grl-podcasts.c
index e3a41fa..6fd0ecb 100644
--- a/src/media/podcasts/grl-podcasts.c
+++ b/src/media/podcasts/grl-podcasts.c
@@ -545,13 +545,13 @@ duration_to_seconds (const gchar *str)
static gboolean
mime_is_video (const gchar *mime)
{
- return mime && strstr (mime, "video") != NULL;
+ return mime && g_str_has_prefix (mime, "video/") != NULL;
}
static gboolean
mime_is_audio (const gchar *mime)
{
- return mime && strstr (mime, "audio") != NULL;
+ return mime && g_str_has_prefix (mime, "audio/") != NULL;
}
static gchar *
diff --git a/src/media/youtube/grl-youtube.c b/src/media/youtube/grl-youtube.c
index 7068d69..c2988c9 100644
--- a/src/media/youtube/grl-youtube.c
+++ b/src/media/youtube/grl-youtube.c
@@ -1228,7 +1228,7 @@ get_video_id_from_url (const gchar *url)
return NULL;
}
- marker = strstr (url, YOUTUBE_WATCH_URL);
+ marker = g_str_has_prefix (url, YOUTUBE_WATCH_URL);
if (!marker) {
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]