You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2011/03/08 03:22:17 UTC
svn commit: r1079089 - in /subversion/trunk/subversion/libsvn_wc:
wc_db_pdh.c wc_db_private.h
Author: hwright
Date: Tue Mar 8 02:22:16 2011
New Revision: 1079089
URL: http://svn.apache.org/viewvc?rev=1079089&view=rev
Log:
Put the wcroot path cache into the svn_wc__db_t object, rather than
function-static variables. This also allows us to use the db->state_pool
for allocations.
* subversion/libsvn_wc/wc_db_pdh.c
(get_path_kind): Use the members of the cache instead of static values.
(svn_wc__db_open): Note that we don't need to further initialize the
cache values.
* subversion/libsvn_wc/wc_db_private.h
(parse_cache): New member which contains the cache values.
Modified:
subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c
subversion/trunk/subversion/libsvn_wc/wc_db_private.h
Modified: subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c?rev=1079089&r1=1079088&r2=1079089&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c Tue Mar 8 02:22:16 2011
@@ -96,10 +96,6 @@ get_path_kind(svn_wc__db_t *db,
svn_node_kind_t *kind,
apr_pool_t *scratch_pool)
{
- static char *cached_abspath = NULL;
- static size_t cache_size = 0;
- static svn_node_kind_t cached_kind;
-
svn_boolean_t special;
size_t abspath_size;
@@ -110,25 +106,26 @@ get_path_kind(svn_wc__db_t *db,
Using malloc()/free() divorces us from the db->state_pool, and a set
of possible memory leaks associated with using it. */
- if (cached_abspath && strcmp(cached_abspath, local_abspath) == 0)
+ if (db->parse_cache.abspath
+ && strcmp(db->parse_cache.abspath, local_abspath) == 0)
{
/* Cache hit! */
- *kind = cached_kind;
+ *kind = db->parse_cache.kind;
return SVN_NO_ERROR;
}
abspath_size = strlen(local_abspath);
- if (abspath_size >= cache_size)
+ if (abspath_size >= db->parse_cache.size)
{
- free(cached_abspath);
- cache_size = abspath_size * 2 + 1;
- cached_abspath = malloc(cache_size);
+ db->parse_cache.size = abspath_size * 2 + 1;
+ db->parse_cache.abspath = apr_palloc(db->state_pool,
+ db->parse_cache.size);
}
- strcpy(cached_abspath, local_abspath);
+ strcpy(db->parse_cache.abspath, local_abspath);
- SVN_ERR(svn_io_check_special_path(local_abspath, &cached_kind,
+ SVN_ERR(svn_io_check_special_path(local_abspath, &db->parse_cache.kind,
&special /* unused */, scratch_pool));
- *kind = cached_kind;
+ *kind = db->parse_cache.kind;
return SVN_NO_ERROR;
}
@@ -190,6 +187,9 @@ svn_wc__db_open(svn_wc__db_t **db,
(*db)->auto_upgrade = auto_upgrade;
(*db)->enforce_empty_wq = enforce_empty_wq;
(*db)->dir_data = apr_hash_make(result_pool);
+
+ /* Don't need to initialize (*db)->parse_cache, due to the calloc above */
+
(*db)->state_pool = result_pool;
return SVN_NO_ERROR;
Modified: subversion/trunk/subversion/libsvn_wc/wc_db_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_private.h?rev=1079089&r1=1079088&r2=1079089&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_private.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_private.h Tue Mar 8 02:22:16 2011
@@ -52,6 +52,15 @@ struct svn_wc__db_t {
const char *local_abspath -> svn_wc__db_wcroot_t *wcroot */
apr_hash_t *dir_data;
+ /* A few members to assist with caching of kind values for paths. See
+ get_path_kind() for use. */
+ struct
+ {
+ char *abspath;
+ size_t size;
+ svn_node_kind_t kind;
+ } parse_cache;
+
/* As we grow the state of this DB, allocate that state here. */
apr_pool_t *state_pool;
};
Re: svn commit: r1079089 - in /subversion/trunk/subversion/libsvn_wc:
wc_db_pdh.c wc_db_private.h
Posted by Greg Stein <gs...@gmail.com>.
On Mon, Mar 7, 2011 at 21:22, <hw...@apache.org> wrote:
>...
> +++ subversion/trunk/subversion/libsvn_wc/wc_db_private.h Tue Mar 8 02:22:16 2011
> @@ -52,6 +52,15 @@ struct svn_wc__db_t {
> const char *local_abspath -> svn_wc__db_wcroot_t *wcroot */
> apr_hash_t *dir_data;
>
> + /* A few members to assist with caching of kind values for paths. See
> + get_path_kind() for use. */
> + struct
> + {
> + char *abspath;
> + size_t size;
> + svn_node_kind_t kind;
> + } parse_cache;
How about just using an svn_stringbuf_t and svn_stringbuf_set() ?
That's really all you're doing here, but ... manually.
Cheers,
-g