[epiphany] Purge unnecessary use of g_str_equal



commit d77ba5191af09bfabcecfa541b13a4268ccbece5
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Wed Sep 13 09:43:40 2017 -0500

    Purge unnecessary use of g_str_equal
    
    This function is intended for use in hash tables.

 TODO                                           |    1 -
 embed/ephy-embed-prefs.c                       |    8 ++++----
 embed/ephy-embed-utils.c                       |    6 +++---
 embed/web-extension/ephy-web-extension.c       |    2 +-
 lib/ephy-file-helpers.c                        |    4 ++--
 lib/ephy-smaps.c                               |   16 ++++++++--------
 lib/ephy-uri-helpers.c                         |    2 +-
 lib/history/ephy-history-service-hosts-table.c |    2 +-
 src/ephy-session.c                             |    2 +-
 src/ephy-shell.c                               |    2 +-
 src/profile-migrator/ephy-profile-migrator.c   |    4 ++--
 tests/ephy-download-test.c                     |    2 +-
 tests/ephy-web-view-test.c                     |    4 ++--
 13 files changed, 27 insertions(+), 28 deletions(-)
---
diff --git a/TODO b/TODO
index 31f8f96..7ec1f0d 100644
--- a/TODO
+++ b/TODO
@@ -12,4 +12,3 @@ Some TODO items, in no particular order:
 - We practically don't test any part of Epiphany, change that (how do
   you test UI code? There's like 3 or 4 frameworks for this, pick one?
   What does Chrome do?)
-- g_str_equal -> g_strcmp0 or strcmp except in hash maps
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index 04c3046..951756d 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -244,7 +244,7 @@ normalize_languages (char **languages)
   langs = g_ptr_array_new ();
 
   for (i = 0; languages && languages[i]; i++) {
-    if (g_str_equal (languages[i], "system")) {
+    if (!strcmp (languages[i], "system")) {
       char **sys_langs = ephy_langs_get_languages ();
       int j;
 
@@ -314,11 +314,11 @@ ephy_embed_prefs_set_cookie_accept_policy (WebKitCookieManager *cookie_manager,
 {
   WebKitCookieAcceptPolicy policy;
 
-  if (g_str_equal (settings_policy, "never"))
+  if (!strcmp (settings_policy, "never"))
     policy = WEBKIT_COOKIE_POLICY_ACCEPT_NEVER;
-  else if (g_str_equal (settings_policy, "always"))
+  else if (!strcmp (settings_policy, "always"))
     policy = WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS;
-  else if (g_str_equal (settings_policy, "no-third-party"))
+  else if (!strcmp (settings_policy, "no-third-party"))
     policy = WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY;
   else {
     g_warn_if_reached ();
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index 5e8b26c..24cd4e1 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -151,7 +151,7 @@ is_public_domain (const char *address)
     return FALSE;
 
   if (g_regex_match (get_domain_regex (), host, 0, NULL)) {
-    if (g_str_equal (host, "localhost"))
+    if (!strcmp (host, "localhost"))
       retval = TRUE;
     else {
       const char *end;
@@ -237,7 +237,7 @@ ephy_embed_utils_normalize_address (const char *address)
   if (ephy_embed_utils_address_is_existing_absolute_filename (address))
     return g_strconcat ("file://", address, NULL);
 
-  if (g_str_has_prefix (address, "about:") && !g_str_equal (address, "about:blank"))
+  if (g_str_has_prefix (address, "about:") && strcmp (address, "about:blank"))
     return g_strconcat (EPHY_ABOUT_SCHEME, address + strlen ("about"), NULL);
 
   if (!ephy_embed_utils_address_has_web_scheme (address)) {
@@ -327,7 +327,7 @@ ephy_embed_utils_is_no_show_address (const char *address)
     return FALSE;
 
   for (i = 0; do_not_show_address[i]; i++)
-    if (g_str_equal (address, do_not_show_address[i]))
+    if (!strcmp (address, do_not_show_address[i]))
       return TRUE;
 
   return FALSE;
diff --git a/embed/web-extension/ephy-web-extension.c b/embed/web-extension/ephy-web-extension.c
index 122210f..02d5fd7 100644
--- a/embed/web-extension/ephy-web-extension.c
+++ b/embed/web-extension/ephy-web-extension.c
@@ -603,7 +603,7 @@ pre_fill_form (EphyEmbedFormAuth *form_auth)
     g_object_get (password_node, "name", &password_field_name, NULL);
 
   /* The username node is empty, so pre-fill with the default. */
-  if (username != NULL && g_str_equal (username, ""))
+  if (!g_strcmp0 (username, ""))
     g_clear_pointer (&username, g_free);
 
   uri_str = soup_uri_to_string (uri, FALSE);
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 7c18753..249cf06 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -141,9 +141,9 @@ ephy_file_get_downloads_dir (void)
   download_dir = g_settings_get_string (EPHY_SETTINGS_STATE,
                                         EPHY_PREFS_STATE_DOWNLOAD_DIR);
 
-  if (g_str_equal (download_dir, "Desktop"))
+  if (!g_strcmp0 (download_dir, "Desktop"))
     download_dir = ephy_file_desktop_dir ();
-  if (g_str_equal (download_dir, "Downloads") ||
+  if (!g_strcmp0 (download_dir, "Downloads") ||
       g_path_is_absolute (download_dir) != TRUE)
     download_dir = ephy_file_download_dir ();
 
diff --git a/lib/ephy-smaps.c b/lib/ephy-smaps.c
index 14dd442..f298c17 100644
--- a/lib/ephy-smaps.c
+++ b/lib/ephy-smaps.c
@@ -250,19 +250,19 @@ static void ephy_smaps_pid_to_html (EphySMaps *smaps, GString *str, pid_t pid, E
       char *name = g_match_info_fetch (match_info, 1);
       char **size = NULL;
 
-      if (g_str_equal (name, "Size"))
+      if (!strcmp (name, "Size"))
         size = &vma->size;
-      else if (g_str_equal (name, "Rss"))
+      else if (!strcmp (name, "Rss"))
         size = &vma->rss;
-      else if (g_str_equal (name, "Pss"))
+      else if (!strcmp (name, "Pss"))
         size = &vma->pss;
-      else if (g_str_equal (name, "Shared_Clean"))
+      else if (!strcmp (name, "Shared_Clean"))
         size = &vma->shared_clean;
-      else if (g_str_equal (name, "Shared_Dirty"))
+      else if (!strcmp (name, "Shared_Dirty"))
         size = &vma->shared_dirty;
-      else if (g_str_equal (name, "Private_Clean"))
+      else if (!strcmp (name, "Private_Clean"))
         size = &vma->private_clean;
-      else if (g_str_equal (name, "Private_Dirty"))
+      else if (!strcmp (name, "Private_Dirty"))
         size = &vma->private_dirty;
 
       if (size)
@@ -421,7 +421,7 @@ static void ephy_smaps_pid_children_to_html (EphySMaps *smaps, GString *str, pid
     pid_t pid, ppid;
     EphyProcess process;
 
-    if (g_str_equal (name, "self"))
+    if (!strcmp (name, "self"))
       continue;
 
     pid = get_pid_from_proc_name (name);
diff --git a/lib/ephy-uri-helpers.c b/lib/ephy-uri-helpers.c
index d18c4a3..7b00593 100644
--- a/lib/ephy-uri-helpers.c
+++ b/lib/ephy-uri-helpers.c
@@ -182,7 +182,7 @@ is_garbage (const char *name,
     if (fields[i].host != NULL &&
         !g_str_has_suffix (host, fields[i].host))
       continue;
-    if (g_str_equal (fields[i].field, name))
+    if (!g_strcmp0 (fields[i].field, name))
       return TRUE;
   }
 
diff --git a/lib/history/ephy-history-service-hosts-table.c b/lib/history/ephy-history-service-hosts-table.c
index 77aec64..2c911dc 100644
--- a/lib/history/ephy-history-service-hosts-table.c
+++ b/lib/history/ephy-history-service-hosts-table.c
@@ -364,7 +364,7 @@ get_hostname_and_locations (const gchar *url, gchar **hostname)
     char *location;
     char *tmp;
 
-    if (g_str_equal (scheme, "https")) {
+    if (!strcmp (scheme, "https")) {
       /* If scheme is https, we still fake http. */
       location = g_strconcat ("http://";, *hostname, "/", NULL);
       host_locations = g_list_append (host_locations, location);
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 4d6ac54..76b220a 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -563,7 +563,7 @@ session_tab_new (EphyEmbed   *embed,
   /* Do not store ephy-about: URIs, they are not valid for loading. */
   if (g_str_has_prefix (address, EPHY_ABOUT_SCHEME)) {
     session_tab->url = g_strconcat ("about", address + EPHY_ABOUT_SCHEME_LEN, NULL);
-  } else if (g_str_equal (address, "about:blank")) {
+  } else if (!strcmp (address, "about:blank")) {
     /* EphyWebView address is NULL between load_uri() and WEBKIT_LOAD_STARTED,
      * but WebKitWebView knows the pending API request URL, so use that instead of about:blank.
      */
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index efa7f54..5f9bf33 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -1124,7 +1124,7 @@ open_uris_data_new (EphyShell       *shell,
   fullscreen_lockdown = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
                                                 EPHY_PREFS_LOCKDOWN_FULLSCREEN);
 
-  have_uris = uris && !(g_strv_length ((char **)uris) == 1 && g_str_equal (uris[0], ""));
+  have_uris = uris && !(g_strv_length ((char **)uris) == 1 && !g_strcmp0 (uris[0], ""));
 
   if (startup_flags & EPHY_STARTUP_NEW_WINDOW && !fullscreen_lockdown) {
     data->window = ephy_window_new ();
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c
index a408d6a..549c395 100644
--- a/src/profile-migrator/ephy-profile-migrator.c
+++ b/src/profile-migrator/ephy-profile-migrator.c
@@ -781,7 +781,7 @@ migrate_adblock_filters (void)
         char *url;
 
         url = g_strstrip (filter_list[i]);
-        if (url[0] != '\0' && !g_str_equal (url, ADBLOCK_DEFAULT_FILTER_URL))
+        if (url[0] != '\0' && strcmp (url, ADBLOCK_DEFAULT_FILTER_URL))
           g_ptr_array_add (filters_array, g_strdup (url));
       }
 
@@ -868,7 +868,7 @@ static gboolean
 is_deprecated_setting (const char *setting)
 {
   for (guint i = 0; i < G_N_ELEMENTS (deprecated_settings); i++) {
-    if (g_str_equal (setting, deprecated_settings[i]))
+    if (!strcmp (setting, deprecated_settings[i]))
       return TRUE;
   }
 
diff --git a/tests/ephy-download-test.c b/tests/ephy-download-test.c
index e2184bc..b1421b7 100644
--- a/tests/ephy-download-test.c
+++ b/tests/ephy-download-test.c
@@ -57,7 +57,7 @@ server_callback (SoupServer        *server,
 {
   soup_message_set_status (msg, SOUP_STATUS_OK);
 
-  if (g_str_equal (path, "/cancelled"))
+  if (!strcmp (path, "/cancelled"))
     soup_message_set_status (msg, SOUP_STATUS_CANT_CONNECT);
 
   soup_message_body_append (msg->response_body, SOUP_MEMORY_STATIC,
diff --git a/tests/ephy-web-view-test.c b/tests/ephy-web-view-test.c
index f94ddfc..4274584 100644
--- a/tests/ephy-web-view-test.c
+++ b/tests/ephy-web-view-test.c
@@ -46,9 +46,9 @@ server_callback (SoupServer        *server,
                  SoupClientContext *context,
                  gpointer           data)
 {
-  if (g_str_equal (path, "/cancelled"))
+  if (!strcmp (path, "/cancelled"))
     soup_message_set_status (msg, SOUP_STATUS_CANT_CONNECT);
-  else if (g_str_equal (path, "/redirect")) {
+  else if (!strcmp (path, "/redirect")) {
     soup_message_set_status (msg, SOUP_STATUS_MOVED_PERMANENTLY);
     soup_message_headers_append (msg->response_headers, "Location", "/redirect-result");
   } else


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