Rev 1878: load default config just once. in file:///data/jelmer/bzr-svn/trunk/

Jelmer Vernooij jelmer at samba.org
Tue Sep 9 02:10:00 BST 2008


At file:///data/jelmer/bzr-svn/trunk/

------------------------------------------------------------
revno: 1878
revision-id: jelmer at samba.org-20080909010958-rnsv5ofpgip5w0z6
parent: jelmer at samba.org-20080909010345-itch9teq3ng1lhwj
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Tue 2008-09-09 03:09:58 +0200
message:
  load default config just once.
modified:
  util.c                         util.c-20080531154025-s8ef6ej9tytsnkkw-1
=== modified file 'util.c'
--- a/util.c	2008-09-09 00:32:05 +0000
+++ b/util.c	2008-09-09 01:09:58 +0000
@@ -401,6 +401,22 @@
 	return NULL;
 }
 
+static apr_hash_t *get_default_config(void)
+{
+	static bool initialised = false;
+	static apr_pool_t *pool = NULL;
+	static apr_hash_t *default_config = NULL;
+
+	if (!initialised) {
+		pool = Pool(NULL);
+		RUN_SVN_WITH_POOL(pool, 
+					  svn_config_get_config(&default_config, NULL, pool));
+		initialised = true;
+	}
+
+	return default_config;
+}
+
 apr_hash_t *config_hash_from_object(PyObject *config, apr_pool_t *pool)
 {
 	Py_ssize_t idx = 0;
@@ -409,9 +425,7 @@
 	PyObject *dict;
 
 	if (config == Py_None) {
-		RUN_SVN_WITH_POOL(pool, 
-					  svn_config_get_config(&config_hash, NULL, pool));
-		return config_hash;
+		return get_default_config();
 	}
 
 	config_hash = apr_hash_make(pool);




More information about the bazaar-commits mailing list