[grilo-plugins/0.1.x] plugins: Prefer g_str_has_prefix() over strstr
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins/0.1.x] plugins: Prefer g_str_has_prefix() over strstr
- Date: Wed, 11 Jul 2012 08:53:04 +0000 (UTC)
commit 5e66fa43bd88342e8216f4db7dfda27b1a353b89
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 e55e332..ddbbcd0 100644
--- a/src/media/bookmarks/grl-bookmarks.c
+++ b/src/media/bookmarks/grl-bookmarks.c
@@ -329,13 +329,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 c0bd3c6..de765f5 100644
--- a/src/media/filesystem/grl-filesystem.c
+++ b/src/media/filesystem/grl-filesystem.c
@@ -254,19 +254,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 b3ee744..ab995aa 100644
--- a/src/media/podcasts/grl-podcasts.c
+++ b/src/media/podcasts/grl-podcasts.c
@@ -559,13 +559,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 195237d..a688766 100644
--- a/src/media/youtube/grl-youtube.c
+++ b/src/media/youtube/grl-youtube.c
@@ -1223,7 +1223,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]