[libsoup] Simplify soup_host_matches_host()



commit 5e50df9fe36c262b0f0741dfc679b9336582893a
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Wed Aug 8 13:53:58 2018 +0300

    Simplify soup_host_matches_host()
    
    There is no need for a hand-written iteration finding a suffix.
    Use g_str_has_suffix() instead which is cleaner.

 libsoup/soup-misc.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
---
diff --git a/libsoup/soup-misc.c b/libsoup/soup-misc.c
index c583d901..2cf6b0f6 100644
--- a/libsoup/soup-misc.c
+++ b/libsoup/soup-misc.c
@@ -257,9 +257,6 @@ const char soup_char_attributes[] = {
 gboolean
 soup_host_matches_host (const gchar *host, const gchar *compare_with)
 {
-       char *match;
-       int dlen;
-
        g_return_val_if_fail (host != NULL, FALSE);
        g_return_val_if_fail (compare_with != NULL, FALSE);
 
@@ -269,11 +266,5 @@ soup_host_matches_host (const gchar *host, const gchar *compare_with)
                return FALSE;
        if (!g_ascii_strcasecmp (host + 1, compare_with))
                return TRUE;
-       dlen = strlen (host);
-       while ((match = strstr (compare_with, host))) {
-               if (!match[dlen])
-                       return TRUE;
-               compare_with = match + 1;
-       }
-       return FALSE;
+       return g_str_has_suffix (compare_with, host);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]