[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH][merge-tracking] remove redundant for loop in svn_fs_merge_info__get_merge_info

From: Daniel Berlin <dberlin_at_dberlin.org>
Date: 2006-10-10 21:23:06 CEST

> Index: subversion/libsvn_fs_util/merge-info-sqlite-index.c
> ===================================================================
> --- subversion/libsvn_fs_util/merge-info-sqlite-index.c (revision 21862)
> +++ subversion/libsvn_fs_util/merge-info-sqlite-index.c (working copy)
> @@ -519,18 +519,12 @@
> for (i = 0; i < paths->nelts; i++)
> {
> const char *path = APR_ARRAY_IDX(paths, i, const char *);
> + apr_hash_t *currhash;
> + svn_stringbuf_t *mergestring;
>
> SVN_ERR (get_merge_info_for_path (db, path, rev, *mergeinfo,
> mergeinfo_cache, TRUE,
> include_parents, pool));
> - }
> -

Uh, changing this like you have would be a bug waiting to happen.
There is no guarantee that *mergeinfo isn't going to get info about
path from a *later* call to get_merge_info_for_path, so it's not
enough to just lookup the info immediately after the call for *that*
path.

That is why they are two loops, one to get all the info, and then one
to process it.

> - for (i = 0; i < paths->nelts; i++)
> - {
> - svn_stringbuf_t *mergestring;
> - apr_hash_t *currhash;
> - const char *path = APR_ARRAY_IDX(paths, i, const char *);
> -
> currhash = apr_hash_get(*mergeinfo, path, APR_HASH_KEY_STRING);
> if (currhash)
> {
> @@ -539,6 +533,7 @@
> apr_hash_set(*mergeinfo, path, APR_HASH_KEY_STRING, mergestring->data);
> }
> }
> +
> SQLITE_ERR(sqlite3_close(db), db);
> return SVN_NO_ERROR;
> }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Oct 10 21:23:23 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.