diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2008-06-21 15:39:16 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2008-06-21 15:39:16 +0000 |
commit | c580f097f14fce63bc6d06d1d07c188f50dd88b6 (patch) | |
tree | 8dd0b43051c0131d8887151ab03ffe17c49020e7 /usr.bin/cvs/util.c | |
parent | ba611d76d5d400a1020fe2602750c348f1adf039 (diff) |
add a hash table mechanism based upon hcreate(3) but one that allows
us to maintain multiple hash tables concurrently.
immediatly start using it to keep track of what directories
we have already created and what CVS dirs we already created so
we do not recreate them when we do not need to.
we will be switching more internals to use this soon.
rejoice for cheaper lookups.
ok tobias@
Diffstat (limited to 'usr.bin/cvs/util.c')
-rw-r--r-- | usr.bin/cvs/util.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c index 3ad983df1c3..339179155e1 100644 --- a/usr.bin/cvs/util.c +++ b/usr.bin/cvs/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.146 2008/06/14 03:19:15 joris Exp $ */ +/* $OpenBSD: util.c,v 1.147 2008/06/21 15:39:15 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org> @@ -41,6 +41,7 @@ #include "cvs.h" #include "remote.h" +#include "hash.h" extern int print_stdout; extern int build_dirs; @@ -525,6 +526,15 @@ cvs_mkadmin(const char *path, const char *root, const char *repo, FILE *fp; int fd; char buf[MAXPATHLEN]; + struct hash_data *hdata, hd; + + hdata = hash_table_find(&created_cvs_directories, path, strlen(path)); + if (hdata != NULL) + return; + + hd.h_key = xstrdup(path); + hd.h_data = NULL; + hash_table_enter(&created_cvs_directories, &hd); if (cvs_server_active == 0) cvs_log(LP_TRACE, "cvs_mkadmin(%s, %s, %s, %s, %s)", @@ -578,9 +588,18 @@ cvs_mkpath(const char *path, char *tag) CVSENTRIES *ent; FILE *fp; size_t len; + struct hash_data *hdata, hd; char *entry, sticky[CVS_REV_BUFSZ]; char *sp, *dp, *dir, *p, rpath[MAXPATHLEN], repo[MAXPATHLEN]; + hdata = hash_table_find(&created_directories, path, strlen(path)); + if (hdata != NULL) + return; + + hd.h_key = xstrdup(path); + hd.h_data = NULL; + hash_table_enter(&created_directories, &hd); + if (current_cvsroot->cr_method != CVS_METHOD_LOCAL || cvs_server_active == 1) cvs_validate_directory(path); |