summaryrefslogtreecommitdiff
path: root/gcc/java/jcf-io.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/java/jcf-io.c')
-rw-r--r--gcc/java/jcf-io.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/gcc/java/jcf-io.c b/gcc/java/jcf-io.c
index 0fe30b30ca5..97a3c0fbc68 100644
--- a/gcc/java/jcf-io.c
+++ b/gcc/java/jcf-io.c
@@ -31,7 +31,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
#include "jcf.h"
#include "tree.h"
#include "java-tree.h"
-#include "hashtab.h"
+#include "hash-table.h"
#include <dirent.h>
#include "zlib.h"
@@ -271,20 +271,34 @@ find_classfile (char *filename, JCF *jcf, const char *dep_name)
return open_class (filename, jcf, fd, dep_name);
}
-/* Returns 1 if the CLASSNAME (really a char *) matches the name
- stored in TABLE_ENTRY (also a char *). */
-static int
-memoized_class_lookup_eq (const void *table_entry, const void *classname)
+/* Hash table helper. */
+
+struct charstar_hash : typed_noop_remove <char>
+{
+ typedef const char T;
+ static inline hashval_t hash (const T *candidate);
+ static inline bool equal (const T *existing, const T *candidate);
+};
+
+inline hashval_t
+charstar_hash::hash (const T *candidate)
{
- return strcmp ((const char *)classname, (const char *)table_entry) == 0;
+ return htab_hash_string (candidate);
}
+inline bool
+charstar_hash::equal (const T *existing, const T *candidate)
+{
+ return strcmp (existing, candidate) == 0;
+}
+
+
/* A hash table keeping track of class names that were not found
during class lookup. (There is no need to cache the values
associated with names that were found; they are saved in
IDENTIFIER_CLASS_VALUE.) */
-static htab_t memoized_class_lookups;
+static hash_table <charstar_hash> memoized_class_lookups;
/* Returns a freshly malloc'd string with the fully qualified pathname
of the .class file for the class CLASSNAME. CLASSNAME must be
@@ -306,16 +320,13 @@ find_class (const char *classname, int classname_length, JCF *jcf)
hashval_t hash;
/* Create the hash table, if it does not already exist. */
- if (!memoized_class_lookups)
- memoized_class_lookups = htab_create (37,
- htab_hash_string,
- memoized_class_lookup_eq,
- NULL);
+ if (!memoized_class_lookups.is_created ())
+ memoized_class_lookups.create (37);
/* Loop for this class in the hashtable. If it is present, we've
already looked for this class and failed to find it. */
- hash = htab_hash_string (classname);
- if (htab_find_with_hash (memoized_class_lookups, classname, hash))
+ hash = charstar_hash::hash (classname);
+ if (memoized_class_lookups.find_with_hash (classname, hash))
return NULL;
/* Allocate and zero out the buffer, since we don't explicitly put a
@@ -390,8 +401,8 @@ find_class (const char *classname, int classname_length, JCF *jcf)
/* Remember that this class could not be found so that we do not
have to look again. */
- *htab_find_slot_with_hash (memoized_class_lookups, classname, hash, INSERT)
- = (void *) CONST_CAST (char *, classname);
+ *memoized_class_lookups.find_slot_with_hash (classname, hash, INSERT)
+ = classname;
return NULL;
found: