[Xfce4-commits] <midori:master> Use strncmp instead of g_str_has_prefix to optimize sokoke_magic_uri
Christian Dywan
noreply at xfce.org
Wed Feb 10 19:54:01 CET 2010
Updating branch refs/heads/master
to 060c0b69407dc99caa996dd155d9b91a463fdccc (commit)
from ee51a8c87fbf0be066264bf8b022b2fe293e174f (commit)
commit 060c0b69407dc99caa996dd155d9b91a463fdccc
Author: Christian Dywan <christian at twotoasts.de>
Date: Mon Feb 8 22:56:09 2010 +0100
Use strncmp instead of g_str_has_prefix to optimize sokoke_magic_uri
midori/sokoke.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/midori/sokoke.c b/midori/sokoke.c
index f307fe7..62a7a1a 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])
More information about the Xfce4-commits
mailing list