From 060c0b69407dc99caa996dd155d9b91a463fdccc Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Mon, 8 Feb 2010 22:56:09 +0100 Subject: [PATCH] Use strncmp instead of g_str_has_prefix to optimize sokoke_magic_uri --- midori/sokoke.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/midori/sokoke.c b/midori/sokoke.c index f307fe74..62a7a1ac 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -598,12 +598,12 @@ sokoke_magic_uri (const gchar* uri, katze_array_is_a (search_engines, KATZE_TYPE_ITEM), NULL); /* Just return if it's a javascript: or mailto: uri */ - if (g_str_has_prefix (uri, "javascript:") - || g_str_has_prefix (uri, "mailto:") - || g_str_has_prefix (uri, "tel:") - || g_str_has_prefix (uri, "callto:") - || g_str_has_prefix (uri, "data:") - || g_str_has_prefix (uri, "about:")) + if (!strncmp (uri, "javascript:", 11) + || !strncmp (uri, "mailto:", 7) + || !strncmp (uri, "tel:", 4) + || !strncmp (uri, "callto:", 7) + || !strncmp (uri, "data:", 5) + || !strncmp (uri, "about:", 6)) return g_strdup (uri); /* Add file:// if we have a local path */ if (g_path_is_absolute (uri)) @@ -620,7 +620,7 @@ sokoke_magic_uri (const gchar* uri, ((search = strchr (uri, ':')) || (search = strchr (uri, '@'))) && search[0] && !g_ascii_isalpha (search[1])) return sokoke_idn_to_punycode (g_strconcat ("http://", uri, NULL)); - if (!strcmp (uri, "localhost") || g_str_has_prefix (uri, "localhost/")) + if (!strncmp (uri, "localhost", 9) && (uri[9] == '\0' || uri[9] == '/')) return g_strconcat ("http://", uri, NULL); parts = g_strsplit (uri, ".", 0); if (!search && parts[0] && parts[1]) -- 2.39.5