From c580f097f14fce63bc6d06d1d07c188f50dd88b6 Mon Sep 17 00:00:00 2001 From: Joris Vink Date: Sat, 21 Jun 2008 15:39:16 +0000 Subject: 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@ --- usr.bin/cvs/util.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'usr.bin/cvs/util.c') 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 * Copyright (c) 2005, 2006 Joris Vink @@ -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); -- cgit v1.2.3