You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ko...@apache.org on 2019/10/09 21:53:31 UTC

svn commit: r1868204 - in /subversion/trunk/subversion: include/private/svn_repos_private.h libsvn_repos/dump_editor.c libsvn_repos/fs-wrap.c svnrdump/load_editor.c svnrdump/util.c

Author: kotkov
Date: Wed Oct  9 21:53:30 2019
New Revision: 1868204

URL: http://svn.apache.org/viewvc?rev=1868204&view=rev
Log:
Adjust lifetime of the result returned from svn_repos__normalize_prop().

Previously, this function would make an unconditional copy of the value into
the result pool.  While this may look convenient in some of the cases, there
is a downside of making unnecessary copies even if no normalization happened.

Instead of that, let's give the calling site control over the results' lifetime
by not making the copy if the input did not change.  The callers may still dup()
the value if they need to, but with this approach there are no unavoidable
copies in various situations, such as where we would like to only update the
value if it changed or where we don't have an appropriate scratch pool, but
need to normalize the property value anyway.

* subversion/include/private/svn_repos_private.h
  (svn_repos__normalize_prop): Adjust documentation.

* subversion/libsvn_repos/fs-wrap.c
  (svn_repos__normalize_prop): Do not duplicate the input if no normalization
   is required.

* subversion/libsvn_repos/dump_editor.c
  (normalize_props): Adjust call to svn_repos__normalize_prop(), explicitly
   duplicate the property value into the result pool.

* subversion/svnrdump/load_editor.c
  (set_revision_property, set_node_property): Explicitly duplicate the property
   values into the long-living pool.

* subversion/svnrdump/util.c
  (svn_rdump__normalize_props): Adjust call to svn_repos__normalize_prop(),
   explicitly duplicate the property value into the result pool.

Modified:
    subversion/trunk/subversion/include/private/svn_repos_private.h
    subversion/trunk/subversion/libsvn_repos/dump_editor.c
    subversion/trunk/subversion/libsvn_repos/fs-wrap.c
    subversion/trunk/subversion/svnrdump/load_editor.c
    subversion/trunk/subversion/svnrdump/util.c

Modified: subversion/trunk/subversion/include/private/svn_repos_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_repos_private.h?rev=1868204&r1=1868203&r2=1868204&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_repos_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_repos_private.h Wed Oct  9 21:53:30 2019
@@ -86,9 +86,11 @@ svn_repos__validate_prop(const char *nam
  *
  * NAME is used to check that VALUE should be normalized, and if this
  * is the case, VALUE is then normalized, allocated from RESULT_POOL.
- * If no normalization is required, VALUE will be copied to RESULT_POOL
- * unchanged.  If NORMALIZED_P is not NULL, and the normalization
- * happened, set *NORMALIZED_P to non-zero.  If the property is returned
+ * If no normalization happened, *RESULT_P will be set to VALUE, and
+ * no copying of the value will occur.
+ *
+ * If NORMALIZED_P is not NULL, and the normalization happened,
+ * set *NORMALIZED_P to non-zero.  If the property is returned
  * unchanged and NORMALIZED_P is not NULL, then *NORMALIZED_P will be
  * set to zero.  SCRATCH_POOL will be used for temporary allocations.
  */

Modified: subversion/trunk/subversion/libsvn_repos/dump_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/dump_editor.c?rev=1868204&r1=1868203&r2=1868204&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/dump_editor.c (original)
+++ subversion/trunk/subversion/libsvn_repos/dump_editor.c Wed Oct  9 21:53:30 2019
@@ -61,8 +61,8 @@ normalize_props(apr_hash_t **normal_prop
       svn_pool_clear(iterpool);
 
       SVN_ERR(svn_repos__normalize_prop(&value, NULL, key, value,
-                                        result_pool, iterpool));
-      svn_hash_sets(*normal_props, key, value);
+                                        iterpool, iterpool));
+      svn_hash_sets(*normal_props, key, svn_string_dup(value, result_pool));
     }
   svn_pool_destroy(iterpool);
 

Modified: subversion/trunk/subversion/libsvn_repos/fs-wrap.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/fs-wrap.c?rev=1868204&r1=1868203&r2=1868204&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/fs-wrap.c (original)
+++ subversion/trunk/subversion/libsvn_repos/fs-wrap.c Wed Oct  9 21:53:30 2019
@@ -282,7 +282,7 @@ svn_repos__normalize_prop(const svn_stri
     }
   else
     {
-      *result_p = svn_string_dup(value, result_pool);
+      *result_p = value;
       if (normalized_p)
         *normalized_p = FALSE;
     }

Modified: subversion/trunk/subversion/svnrdump/load_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnrdump/load_editor.c?rev=1868204&r1=1868203&r2=1868204&view=diff
==============================================================================
--- subversion/trunk/subversion/svnrdump/load_editor.c (original)
+++ subversion/trunk/subversion/svnrdump/load_editor.c Wed Oct  9 21:53:30 2019
@@ -576,7 +576,8 @@ set_revision_property(void *baton,
     {
       if (! svn_hash_gets(rb->pb->skip_revprops, name))
         svn_hash_sets(rb->revprop_table,
-                      apr_pstrdup(rb->pool, name), value);
+                      apr_pstrdup(rb->pool, name),
+                      svn_string_dup(value, rb->pool));
     }
   else if (rb->head_rev_before_commit == 0
            && ! svn_hash_gets(rb->pb->skip_revprops, name))
@@ -591,9 +592,9 @@ set_revision_property(void *baton,
   /* Remember any datestamp/ author that passes through (see comment
      in close_revision). */
   if (!strcmp(name, SVN_PROP_REVISION_DATE))
-    rb->datestamp = value;
+    rb->datestamp = svn_string_dup(value, rb->pool);
   if (!strcmp(name, SVN_PROP_REVISION_AUTHOR))
-    rb->author = value;
+    rb->author = svn_string_dup(value, rb->pool);
 
   return SVN_NO_ERROR;
 }
@@ -636,7 +637,7 @@ set_node_property(void *baton,
 
   prop = apr_palloc(nb->rb->pool, sizeof (*prop));
   prop->name = apr_pstrdup(pool, name);
-  prop->value = value;
+  prop->value = svn_string_dup(value, pool);
   svn_hash_sets(nb->prop_changes, prop->name, prop);
 
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/svnrdump/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnrdump/util.c?rev=1868204&r1=1868203&r2=1868204&view=diff
==============================================================================
--- subversion/trunk/subversion/svnrdump/util.c (original)
+++ subversion/trunk/subversion/svnrdump/util.c Wed Oct  9 21:53:30 2019
@@ -46,8 +46,8 @@ svn_rdump__normalize_props(apr_hash_t **
       svn_pool_clear(iterpool);
 
       SVN_ERR(svn_repos__normalize_prop(&value, NULL, key, value,
-                                        result_pool, iterpool));
-      svn_hash_sets(*normal_props, key, value);
+                                        iterpool, iterpool));
+      svn_hash_sets(*normal_props, key, svn_string_dup(value, result_pool));
     }
   svn_pool_destroy(iterpool);