Use strncmp instead of g_str_has_prefix to optimize sokoke_magic_uri
This commit is contained in:
parent
ee51a8c87f
commit
060c0b6940
1 changed files with 7 additions and 7 deletions
|
@ -598,12 +598,12 @@ sokoke_magic_uri (const gchar* uri,
|
||||||
katze_array_is_a (search_engines, KATZE_TYPE_ITEM), NULL);
|
katze_array_is_a (search_engines, KATZE_TYPE_ITEM), NULL);
|
||||||
|
|
||||||
/* Just return if it's a javascript: or mailto: uri */
|
/* Just return if it's a javascript: or mailto: uri */
|
||||||
if (g_str_has_prefix (uri, "javascript:")
|
if (!strncmp (uri, "javascript:", 11)
|
||||||
|| g_str_has_prefix (uri, "mailto:")
|
|| !strncmp (uri, "mailto:", 7)
|
||||||
|| g_str_has_prefix (uri, "tel:")
|
|| !strncmp (uri, "tel:", 4)
|
||||||
|| g_str_has_prefix (uri, "callto:")
|
|| !strncmp (uri, "callto:", 7)
|
||||||
|| g_str_has_prefix (uri, "data:")
|
|| !strncmp (uri, "data:", 5)
|
||||||
|| g_str_has_prefix (uri, "about:"))
|
|| !strncmp (uri, "about:", 6))
|
||||||
return g_strdup (uri);
|
return g_strdup (uri);
|
||||||
/* Add file:// if we have a local path */
|
/* Add file:// if we have a local path */
|
||||||
if (g_path_is_absolute (uri))
|
if (g_path_is_absolute (uri))
|
||||||
|
@ -620,7 +620,7 @@ sokoke_magic_uri (const gchar* uri,
|
||||||
((search = strchr (uri, ':')) || (search = strchr (uri, '@'))) &&
|
((search = strchr (uri, ':')) || (search = strchr (uri, '@'))) &&
|
||||||
search[0] && !g_ascii_isalpha (search[1]))
|
search[0] && !g_ascii_isalpha (search[1]))
|
||||||
return sokoke_idn_to_punycode (g_strconcat ("http://", uri, NULL));
|
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);
|
return g_strconcat ("http://", uri, NULL);
|
||||||
parts = g_strsplit (uri, ".", 0);
|
parts = g_strsplit (uri, ".", 0);
|
||||||
if (!search && parts[0] && parts[1])
|
if (!search && parts[0] && parts[1])
|
||||||
|
|
Loading…
Reference in a new issue