subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bre...@apache.org
Subject svn commit: r1548334 - in /subversion/trunk/subversion/svn: log-cmd.c mergeinfo-cmd.c
Date Fri, 06 Dec 2013 00:10:46 GMT
Author: breser
Date: Fri Dec  6 00:10:46 2013
New Revision: 1548334

URL: http://svn.apache.org/r1548334
Log:
Allocate the merge_stack array for the log receivers on demand.

This ends up saving a tiny amount of memory when log is called without -g and
for mergeinfo --log.

* subversion/svn/log-cmd.c
  (svn_cl__log_entry_receiver, svn_cl__log_entry_receiver_xml):  Check the
    merge_stack member before use and make an array if it hasn't already been
    made before adding a member.
  (svn_cl__log): Initialize the merge_stack member of the baton to NULL.

* subversion/svn/mergeinfo-cmd.c
  (mergeinfo_log): Initialize the merge_stack member of the baton to NULL.

Modified:
    subversion/trunk/subversion/svn/log-cmd.c
    subversion/trunk/subversion/svn/mergeinfo-cmd.c

Modified: subversion/trunk/subversion/svn/log-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/log-cmd.c?rev=1548334&r1=1548333&r2=1548334&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/log-cmd.c (original)
+++ subversion/trunk/subversion/svn/log-cmd.c Fri Dec  6 00:10:46 2013
@@ -307,7 +307,9 @@ svn_cl__log_entry_receiver(void *baton,
 
   if (! SVN_IS_VALID_REVNUM(log_entry->revision))
     {
-      apr_array_pop(lb->merge_stack);
+      if (lb->merge_stack)
+        apr_array_pop(lb->merge_stack);
+
       return SVN_NO_ERROR;
     }
 
@@ -331,7 +333,12 @@ svn_cl__log_entry_receiver(void *baton,
                               log_entry->changed_paths2, pool))
     {
       if (log_entry->has_children)
-        APR_ARRAY_PUSH(lb->merge_stack, svn_revnum_t) = log_entry->revision;
+        {
+          if (! lb->merge_stack)
+            lb->merge_stack = apr_array_make(lb->pool, 1, sizeof(svn_revnum_t));
+
+          APR_ARRAY_PUSH(lb->merge_stack, svn_revnum_t) = log_entry->revision;
+        }
 
       return SVN_NO_ERROR;
     }
@@ -389,7 +396,7 @@ svn_cl__log_entry_receiver(void *baton,
         }
     }
 
-  if (lb->merge_stack->nelts > 0)
+  if (lb->merge_stack && lb->merge_stack->nelts > 0)
     {
       int i;
 
@@ -437,7 +444,12 @@ svn_cl__log_entry_receiver(void *baton,
     }
 
   if (log_entry->has_children)
-    APR_ARRAY_PUSH(lb->merge_stack, svn_revnum_t) = log_entry->revision;
+    {
+      if (! lb->merge_stack)
+        lb->merge_stack = apr_array_make(lb->pool, 1, sizeof(svn_revnum_t));
+
+      APR_ARRAY_PUSH(lb->merge_stack, svn_revnum_t) = log_entry->revision;
+    }
 
   return SVN_NO_ERROR;
 }
@@ -504,7 +516,8 @@ svn_cl__log_entry_receiver_xml(void *bat
     {
       svn_xml_make_close_tag(&sb, pool, "logentry");
       SVN_ERR(svn_cl__error_checked_fputs(sb->data, stdout));
-      apr_array_pop(lb->merge_stack);
+      if (lb->merge_stack)
+        apr_array_pop(lb->merge_stack);
 
       return SVN_NO_ERROR;
     }
@@ -515,7 +528,12 @@ svn_cl__log_entry_receiver_xml(void *bat
                               log_entry->changed_paths2, pool))
     {
       if (log_entry->has_children)
-        APR_ARRAY_PUSH(lb->merge_stack, svn_revnum_t) = log_entry->revision;
+        {
+          if (! lb->merge_stack)
+            lb->merge_stack = apr_array_make(lb->pool, 1, sizeof(svn_revnum_t));
+
+          APR_ARRAY_PUSH(lb->merge_stack, svn_revnum_t) = log_entry->revision;
+        }
 
       return SVN_NO_ERROR;
     }
@@ -624,7 +642,12 @@ svn_cl__log_entry_receiver_xml(void *bat
     }
 
   if (log_entry->has_children)
-    APR_ARRAY_PUSH(lb->merge_stack, svn_revnum_t) = log_entry->revision;
+    {
+      if (! lb->merge_stack)
+        lb->merge_stack = apr_array_make(lb->pool, 1, sizeof(svn_revnum_t));
+
+      APR_ARRAY_PUSH(lb->merge_stack, svn_revnum_t) = log_entry->revision;
+    }
   else
     svn_xml_make_close_tag(&sb, pool, "logentry");
 
@@ -752,7 +775,7 @@ svn_cl__log(apr_getopt_t *os,
   lb.depth = opt_state->depth == svn_depth_unknown ? svn_depth_infinity
                                                    : opt_state->depth;
   lb.diff_extensions = opt_state->extensions;
-  lb.merge_stack = apr_array_make(pool, 0, sizeof(svn_revnum_t));
+  lb.merge_stack = NULL;
   lb.search_patterns = opt_state->search_patterns;
   lb.pool = pool;
 

Modified: subversion/trunk/subversion/svn/mergeinfo-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/mergeinfo-cmd.c?rev=1548334&r1=1548333&r2=1548334&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/mergeinfo-cmd.c (original)
+++ subversion/trunk/subversion/svn/mergeinfo-cmd.c Fri Dec  6 00:10:46 2013
@@ -304,7 +304,7 @@ mergeinfo_log(svn_boolean_t finding_merg
       baton->show_diff = FALSE;
       baton->depth = depth;
       baton->diff_extensions = NULL;
-      baton->merge_stack = apr_array_make(pool, 0, sizeof(svn_revnum_t));
+      baton->merge_stack = NULL; 
       baton->search_patterns = NULL;
       baton->pool = pool;
       log_receiver_baton = baton; 



Mime
View raw message