summaryrefslogtreecommitdiff
path: root/gcc/java/jcf-io.c
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2005-09-30 00:33:26 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2005-09-30 00:33:26 +0000
commit55c72ac40c648560636fa26fd2326d16a5c6bd5d (patch)
tree83c0b6cc2a21699fc5a0d65372bad7330a01849c /gcc/java/jcf-io.c
parent9ef9fa96a6908b90269e173dddf184de50191138 (diff)
downloadgcc-55c72ac40c648560636fa26fd2326d16a5c6bd5d.tar.gz
PR java/24120:
* jcf-io.c (memoized_dirlist_hash): New function. (caching_stat): Use it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104809 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java/jcf-io.c')
-rw-r--r--gcc/java/jcf-io.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/gcc/java/jcf-io.c b/gcc/java/jcf-io.c
index 383c7d74878..9b9be0a4f5a 100644
--- a/gcc/java/jcf-io.c
+++ b/gcc/java/jcf-io.c
@@ -311,6 +311,14 @@ typedef struct memoized_dirlist_entry
struct dirent **files;
} memoized_dirlist_entry;
+/* A hash function for a memoized_dirlist_entry. */
+static hashval_t
+memoized_dirlist_hash (const void *entry)
+{
+ const memoized_dirlist_entry *mde = (const memoized_dirlist_entry *) entry;
+ return htab_hash_string (mde->dir);
+}
+
/* Returns true if ENTRY (a memoized_dirlist_entry *) corresponds to
the directory given by KEY (a char *) giving the directory
name. */
@@ -341,11 +349,12 @@ caching_stat (char *filename, struct stat *buf)
char *base;
memoized_dirlist_entry *dent;
void **slot;
+ struct memoized_dirlist_entry temp;
/* If the hashtable has not already been created, create it now. */
if (!memoized_dirlists)
memoized_dirlists = htab_create (37,
- htab_hash_string,
+ memoized_dirlist_hash,
memoized_dirlist_lookup_eq,
NULL);
@@ -364,8 +373,13 @@ caching_stat (char *filename, struct stat *buf)
else
base = filename;
- /* Obtain the entry for this directory from the hash table. */
- slot = htab_find_slot (memoized_dirlists, filename, INSERT);
+ /* Obtain the entry for this directory from the hash table. This
+ approach is ok since we know that the hash function only looks at
+ the directory name. */
+ temp.dir = filename;
+ temp.num_files = 0;
+ temp.files = NULL;
+ slot = htab_find_slot (memoized_dirlists, &temp, INSERT);
if (!*slot)
{
/* We have not already scanned this directory; scan it now. */