[2/3] gcc: use htab_eq_string

Message ID 20210505213317.513520-3-tom@tromey.com
State New
Headers show
Series
  • Add htab_eq_string to libiberty
Related show

Commit Message

Tom Tromey May 5, 2021, 9:33 p.m.
This changes one spot in GCC to use the new htab_eq_string function.

gcc

	* gengtype-state.c (read_state): Use htab_eq_string.
	(string_eq): Remove.
---
 gcc/gengtype-state.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

-- 
2.26.3

Comments

Jason Merrill via Gcc-patches May 6, 2021, 7:26 a.m. | #1
On Thu, May 6, 2021 at 12:43 AM Tom Tromey <tom@tromey.com> wrote:
>

> This changes one spot in GCC to use the new htab_eq_string function.


OK.

> gcc

>

>         * gengtype-state.c (read_state): Use htab_eq_string.

>         (string_eq): Remove.

> ---

>  gcc/gengtype-state.c | 11 +----------

>  1 file changed, 1 insertion(+), 10 deletions(-)

>

> diff --git a/gcc/gengtype-state.c b/gcc/gengtype-state.c

> index 891f2e18a610..a8fde959f4eb 100644

> --- a/gcc/gengtype-state.c

> +++ b/gcc/gengtype-state.c

> @@ -2556,15 +2556,6 @@ equals_type_number (const void *ty1, const void *ty2)

>    return type1->state_number == type2->state_number;

>  }

>

> -static int

> -string_eq (const void *a, const void *b)

> -{

> -  const char *a0 = (const char *)a;

> -  const char *b0 = (const char *)b;

> -

> -  return (strcmp (a0, b0) == 0);

> -}

> -

>

>  /* The function reading the state, called by main from gengtype.c.  */

>  void

> @@ -2588,7 +2579,7 @@ read_state (const char *path)

>    state_seen_types =

>      htab_create (2017, hash_type_number, equals_type_number, NULL);

>    state_ident_tab =

> -    htab_create (4027, htab_hash_string, string_eq, NULL);

> +    htab_create (4027, htab_hash_string, htab_eq_string, NULL);

>    read_state_version (version_string);

>    read_state_srcdir ();

>    read_state_languages ();

> --

> 2.26.3

>

Patch

diff --git a/gcc/gengtype-state.c b/gcc/gengtype-state.c
index 891f2e18a610..a8fde959f4eb 100644
--- a/gcc/gengtype-state.c
+++ b/gcc/gengtype-state.c
@@ -2556,15 +2556,6 @@  equals_type_number (const void *ty1, const void *ty2)
   return type1->state_number == type2->state_number;
 }
 
-static int
-string_eq (const void *a, const void *b)
-{
-  const char *a0 = (const char *)a;
-  const char *b0 = (const char *)b;
-
-  return (strcmp (a0, b0) == 0);
-}
-
 
 /* The function reading the state, called by main from gengtype.c.  */
 void
@@ -2588,7 +2579,7 @@  read_state (const char *path)
   state_seen_types =
     htab_create (2017, hash_type_number, equals_type_number, NULL);
   state_ident_tab =
-    htab_create (4027, htab_hash_string, string_eq, NULL);
+    htab_create (4027, htab_hash_string, htab_eq_string, NULL);
   read_state_version (version_string);
   read_state_srcdir ();
   read_state_languages ();