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

[PATCH]economic use of apr_hash_this

From: Kamesh Jayachandran <kamesh_at_collab.net>
Date: 2006-12-08 11:00:50 CET

Hi All,
This patch attempts to retrieve only what is needed out of apr_hash.

With regards
Kamesh Jayachandran

[[[

Only receive needed items from apr_hash_this, pass NULL for
not-needed items.

* subversion/libsvn_wc/props.c
  (svn_wc__wcprops_write):
   Key is not needed.

* subversion/libsvn_wc/entries.c
  (walker_helper):
   Key-len is not needed.

* subversion/libsvn_wc/log.c
  (log_do_committed):
   Key-len is not needed.

* subversion/libsvn_client/copy.c
  (remove_tmpfiles):
   Key-len and Val are not needed.

* subversion/libsvn_client/commit_util.c
  (look_up_committable):
   Key is not needed.
  (svn_client__do_commit):
   Key and Key-len are not needed.

* subversion/svnlook/main.c
  (print_tree):
   Key and Key-len are not needed.

* subversion/bindings/java/javahl/native/SVNClient.cpp
  (global): Bump up the copyright year.
  (SVNClient::propertyGet):
   Key is not needed.

* subversion/bindings/java/javahl/native/SVNAdmin.cpp
  (global): Bump up the copyright year.
  (SVNAdmin::lslocks):
   Key is not needed.

* subversion/mod_dav_svn/repos.c
  (deliver):
   Key-len is not needed.

* subversion/mod_dav_svn/reports/get-locks.c
  (dav_svn__get_locks_report):
   Key is not needed.

* subversion/tests/svn_test_fs.c
  (global): Bump up the copyright year.
  (get_dir_entries):
   Key and Key-len are not needed.
  (svn_test__validate_tree):
   Val is not needed.

* subversion/libsvn_repos/dump.c
  (write_hash_to_stringbuf):
   Val is not needed.

* subversion/libsvn_repos/load.c
  (global): Bump up the copyright year.
  (remove_node_props):
   Key-len and Val are not needed.

* subversion/libsvn_repos/delta.c
  (delta_dirs):
   Key and Key-len are not needed.

* subversion/libsvn_ra_dav/props.c
  (svn_ra_dav__do_stat):
   Key is not needed.
   Val is not needed.

* subversion/libsvn_ra_dav/fetch.c
  (svn_ra_dav__get_dir):
   Val is not needed.
  (start_element):
   Key is not needed.

* subversion/svnserve/serve.c
  (get_locks):
   Key is not needed.

* subversion/libsvn_fs_fs/fs_fs.c
  (write_final_changed_path_info):
   Key-len is not needed.

Patch by: Kamesh Jayachandran <kamesh@collab.net>
]]]

Index: subversion/libsvn_wc/props.c
===================================================================
--- subversion/libsvn_wc/props.c (revision 22603)
+++ subversion/libsvn_wc/props.c (working copy)
@@ -920,10 +920,9 @@
   for (hi = apr_hash_first(pool, wcprops); hi && ! any_props;
        hi = apr_hash_next(hi))
     {
- const void *key;
       void *val;
 
- apr_hash_this(hi, &key, NULL, &val);
+ apr_hash_this(hi, NULL, NULL, &val);
       proplist = val;
       if (apr_hash_count(proplist) > 0)
         any_props = TRUE;
Index: subversion/libsvn_wc/entries.c
===================================================================
--- subversion/libsvn_wc/entries.c (revision 22603)
+++ subversion/libsvn_wc/entries.c (working copy)
@@ -2743,7 +2743,6 @@
   for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi))
     {
       const void *key;
- apr_ssize_t klen;
       void *val;
       const svn_wc_entry_t *current_entry;
       const char *entrypath;
@@ -2752,7 +2751,7 @@
       if (cancel_func)
         SVN_ERR(cancel_func(cancel_baton));
 
- apr_hash_this(hi, &key, &klen, &val);
+ apr_hash_this(hi, &key, NULL, &val);
       current_entry = val;
 
       if (strcmp(current_entry->name, SVN_WC_ENTRY_THIS_DIR) == 0)
Index: subversion/libsvn_wc/log.c
===================================================================
--- subversion/libsvn_wc/log.c (revision 22603)
+++ subversion/libsvn_wc/log.c (working copy)
@@ -1149,13 +1149,12 @@
       for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi))
         {
           const void *key;
- apr_ssize_t klen;
           void *val;
           const svn_wc_entry_t *cur_entry;
           svn_wc_adm_access_t *entry_access;
                   
           /* Get the next entry */
- apr_hash_this(hi, &key, &klen, &val);
+ apr_hash_this(hi, &key, NULL, &val);
           cur_entry = (svn_wc_entry_t *) val;
                   
           /* Skip each entry that isn't scheduled for deletion. */
Index: subversion/libsvn_client/copy.c
===================================================================
--- subversion/libsvn_client/copy.c (revision 22603)
+++ subversion/libsvn_client/copy.c (working copy)
@@ -481,14 +481,12 @@
   for (hi = apr_hash_first(pool, tempfiles); hi; hi = apr_hash_next(hi))
     {
       const void *key;
- apr_ssize_t keylen;
- void *val;
       svn_node_kind_t kind;
 
       if (cancel_func)
         SVN_ERR(cancel_func(cancel_baton));
 
- apr_hash_this(hi, &key, &keylen, &val);
+ apr_hash_this(hi, &key, NULL, NULL);
       SVN_ERR(svn_io_check_path((const char *)key, &kind, pool));
       if (kind == svn_node_file)
         SVN_ERR(svn_io_remove_file((const char *)key, pool));
Index: subversion/libsvn_client/commit_util.c
===================================================================
--- subversion/libsvn_client/commit_util.c (revision 22603)
+++ subversion/libsvn_client/commit_util.c (working copy)
@@ -134,12 +134,11 @@
 
   for (hi = apr_hash_first(pool, committables); hi; hi = apr_hash_next(hi))
     {
- const void *key;
       void *val;
       apr_array_header_t *these_committables;
       int i;
       
- apr_hash_this(hi, &key, NULL, &val);
+ apr_hash_this(hi, NULL, NULL, &val);
       these_committables = val;
       
       for (i = 0; i < these_committables->nelts; i++)
@@ -1291,8 +1290,6 @@
   /* Transmit outstanding text deltas. */
   for (hi = apr_hash_first(pool, file_mods); hi; hi = apr_hash_next(hi))
     {
- const void *key;
- apr_ssize_t klen;
       struct file_mod_t *mod;
       svn_client_commit_item2_t *item;
       void *val;
@@ -1304,7 +1301,7 @@
       
       svn_pool_clear(subpool);
       /* Get the next entry. */
- apr_hash_this(hi, &key, &klen, &val);
+ apr_hash_this(hi, NULL, NULL, &val);
       mod = val;
 
       /* Transmit the entry. */
Index: subversion/svnlook/main.c
===================================================================
--- subversion/svnlook/main.c (revision 22603)
+++ subversion/svnlook/main.c (working copy)
@@ -1038,13 +1038,11 @@
   subpool = svn_pool_create(pool);
   for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi))
     {
- const void *key;
- apr_ssize_t keylen;
       void *val;
       svn_fs_dirent_t *entry;
 
       svn_pool_clear(subpool);
- apr_hash_this(hi, &key, &keylen, &val);
+ apr_hash_this(hi, NULL, NULL, &val);
       entry = val;
       SVN_ERR(print_tree(root, svn_path_join(path, entry->name, pool),
                          entry->id, (entry->kind == svn_node_dir),
Index: subversion/bindings/java/javahl/native/SVNClient.cpp
===================================================================
--- subversion/bindings/java/javahl/native/SVNClient.cpp (revision 22603)
+++ subversion/bindings/java/javahl/native/SVNClient.cpp (working copy)
@@ -1,7 +1,7 @@
 /**
  * @copyright
  * ====================================================================
- * Copyright (c) 2003 CollabNet. All rights reserved.
+ * Copyright (c) 2003-2006 CollabNet. All rights reserved.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -1246,9 +1246,8 @@
     if (hi == NULL)
         return NULL; // no property with this name
 
- const char *filename;
     svn_string_t *propval;
- apr_hash_this (hi, (const void **)&filename, NULL, (void**)&propval);
+ apr_hash_this (hi, NULL, NULL, (void**)&propval);
 
     if(propval == NULL)
         return NULL;
Index: subversion/bindings/java/javahl/native/SVNAdmin.cpp
===================================================================
--- subversion/bindings/java/javahl/native/SVNAdmin.cpp (revision 22603)
+++ subversion/bindings/java/javahl/native/SVNAdmin.cpp (working copy)
@@ -1,7 +1,7 @@
 /**
  * @copyright
  * ====================================================================
- * Copyright (c) 2003-2004 CollabNet. All rights reserved.
+ * Copyright (c) 2003-2006 CollabNet. All rights reserved.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -667,9 +667,8 @@
     for (hi = apr_hash_first (requestPool.pool(), locks); hi;
             hi = apr_hash_next (hi),i++)
     {
- const void *key;
         void *val;
- apr_hash_this (hi, &key, NULL, &val);
+ apr_hash_this (hi, NULL, NULL, &val);
         svn_lock_t *lock = (svn_lock_t *)val;
         jobject jLock = SVNClient::createJavaLock(lock);
         env->SetObjectArrayElement(ret, i, jLock);
Index: subversion/mod_dav_svn/repos.c
===================================================================
--- subversion/mod_dav_svn/repos.c (revision 22603)
+++ subversion/mod_dav_svn/repos.c (working copy)
@@ -2616,12 +2616,11 @@
                hi; hi = apr_hash_next(hi))
             {
               const void *key;
- apr_ssize_t klen;
               void *val;
               svn_io_dirent_t *dirent;
               svn_fs_dirent_t *ent = apr_pcalloc(resource->pool, sizeof(*ent));
 
- apr_hash_this(hi, &key, &klen, &val);
+ apr_hash_this(hi, &key, NULL, &val);
               dirent = val;
 
               if (dirent->kind != svn_node_dir)
Index: subversion/mod_dav_svn/reports/get-locks.c
===================================================================
--- subversion/mod_dav_svn/reports/get-locks.c (revision 22603)
+++ subversion/mod_dav_svn/reports/get-locks.c (working copy)
@@ -87,7 +87,6 @@
   subpool = svn_pool_create(resource->pool);
   for (hi = apr_hash_first(resource->pool, locks); hi; hi = apr_hash_next(hi))
     {
- const void *key;
       void *val;
       const svn_lock_t *lock;
       const char *path_quoted, *token_quoted;
@@ -96,7 +95,7 @@
       svn_boolean_t owner_base64 = FALSE, comment_base64 = FALSE;
 
       svn_pool_clear(subpool);
- apr_hash_this(hi, &key, NULL, &val);
+ apr_hash_this(hi, NULL, NULL, &val);
       lock = val;
       
       path_quoted = apr_xml_quote_string(subpool, lock->path, 1);
Index: subversion/tests/svn_test_fs.c
===================================================================
--- subversion/tests/svn_test_fs.c (revision 22603)
+++ subversion/tests/svn_test_fs.c (working copy)
@@ -1,7 +1,7 @@
 /* fs-helpers.c --- tests for the filesystem
  *
  * ====================================================================
- * Copyright (c) 2000-2004 CollabNet. All rights reserved.
+ * Copyright (c) 2000-2006 CollabNet. All rights reserved.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -234,13 +234,11 @@
      names */
   for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi))
     {
- const void *key;
- apr_ssize_t keylen;
       void *val;
       svn_fs_dirent_t *dirent;
       const char *full_path;
  
- apr_hash_this(hi, &key, &keylen, &val);
+ apr_hash_this(hi, NULL, NULL, &val);
       dirent = val;
 
       /* Calculate the full path of this entry (by appending the name
@@ -386,9 +384,8 @@
     {
       const void *key;
       apr_ssize_t keylen;
- void *val;
 
- apr_hash_this(hi, &key, &keylen, &val);
+ apr_hash_this(hi, &key, &keylen, NULL);
 
       /* If we don't have an extra entries string, make one. */
       if (! extra_entries)
Index: subversion/libsvn_repos/dump.c
===================================================================
--- subversion/libsvn_repos/dump.c (revision 22603)
+++ subversion/libsvn_repos/dump.c (working copy)
@@ -95,11 +95,10 @@
            this = apr_hash_next(this))
         {
           const void *key;
- void *val;
           apr_ssize_t keylen;
 
- /* Get this key and val. */
- apr_hash_this(this, &key, &keylen, &val);
+ /* Get this key. */
+ apr_hash_this(this, &key, &keylen, NULL);
 
           /* Only output values deleted in hash. */
           if (apr_hash_get(hash, key, keylen))
Index: subversion/libsvn_repos/load.c
===================================================================
--- subversion/libsvn_repos/load.c (revision 22603)
+++ subversion/libsvn_repos/load.c (working copy)
@@ -1,7 +1,7 @@
 /* load.c --- parsing a 'dumpfile'-formatted stream.
  *
  * ====================================================================
- * Copyright (c) 2000-2004 CollabNet. All rights reserved.
+ * Copyright (c) 2000-2006 CollabNet. All rights reserved.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -1104,10 +1104,8 @@
   for (hi = apr_hash_first(nb->pool, proplist); hi; hi = apr_hash_next(hi))
     {
       const void *key;
- apr_ssize_t keylen;
- void *val;
 
- apr_hash_this(hi, &key, &keylen, &val);
+ apr_hash_this(hi, &key, NULL, NULL);
 
       SVN_ERR(svn_fs_change_node_prop(rb->txn_root, nb->path,
                                       (const char *) key, NULL,
Index: subversion/libsvn_repos/delta.c
===================================================================
--- subversion/libsvn_repos/delta.c (revision 22603)
+++ subversion/libsvn_repos/delta.c (working copy)
@@ -1033,9 +1033,7 @@
       for (hi = apr_hash_first(pool, s_entries); hi; hi = apr_hash_next(hi))
         {
           const svn_fs_dirent_t *s_entry;
- const void *key;
           void *val;
- apr_ssize_t klen;
           const char *e_fullpath;
           svn_node_kind_t src_kind;
           
@@ -1043,7 +1041,7 @@
           svn_pool_clear(subpool);
 
           /* KEY is the entry name in source, VAL the dirent */
- apr_hash_this(hi, &key, &klen, &val);
+ apr_hash_this(hi, NULL, NULL, &val);
           s_entry = val;
           src_kind = s_entry->kind;
           e_fullpath = svn_path_join(edit_path, s_entry->name, subpool);
Index: subversion/libsvn_ra_dav/props.c
===================================================================
--- subversion/libsvn_ra_dav/props.c (revision 22603)
+++ subversion/libsvn_ra_dav/props.c (working copy)
@@ -1265,16 +1265,13 @@
      get the item. */
   for (hi = apr_hash_first(pool, resources); hi; hi = apr_hash_next(hi))
     {
- const void *key;
       void *val;
- const char *childname;
       svn_ra_dav_resource_t *resource;
       const svn_string_t *propval;
       apr_hash_index_t *h;
       svn_dirent_t *entry;
 
- apr_hash_this(hi, &key, NULL, &val);
- childname = key;
+ apr_hash_this(hi, NULL, NULL, &val);
       resource = val;
           
       entry = apr_pcalloc(pool, sizeof(*entry));
@@ -1296,8 +1293,7 @@
            h; h = apr_hash_next(h))
         {
           const void *kkey;
- void *vval;
- apr_hash_this(h, &kkey, NULL, &vval);
+ apr_hash_this(h, &kkey, NULL, NULL);
           
           if (strncmp((const char *)kkey, SVN_DAV_PROP_NS_CUSTOM,
                       sizeof(SVN_DAV_PROP_NS_CUSTOM) - 1) == 0)
Index: subversion/libsvn_ra_dav/fetch.c
===================================================================
--- subversion/libsvn_ra_dav/fetch.c (revision 22603)
+++ subversion/libsvn_ra_dav/fetch.c (working copy)
@@ -1081,8 +1081,7 @@
                        h; h = apr_hash_next(h))
                     {
                       const void *kkey;
- void *vval;
- apr_hash_this(h, &kkey, NULL, &vval);
+ apr_hash_this(h, &kkey, NULL, NULL);
                   
                       if (strncmp((const char *) kkey, SVN_DAV_PROP_NS_CUSTOM,
                                   sizeof(SVN_DAV_PROP_NS_CUSTOM) - 1) == 0
@@ -2236,12 +2235,11 @@
               for (hi = apr_hash_first(TOP_DIR(rb).pool, bc_children);
                    hi; hi = apr_hash_next(hi))
                 {
- const void *key;
                   void *val;
                   svn_ra_dav_resource_t *rsrc;
                   const svn_string_t *vc_url;
 
- apr_hash_this(hi, &key, NULL, &val);
+ apr_hash_this(hi, NULL, NULL, &val);
                   rsrc = val;
 
                   vc_url = apr_hash_get(rsrc->propset,
Index: subversion/svnserve/serve.c
===================================================================
--- subversion/svnserve/serve.c (revision 22603)
+++ subversion/svnserve/serve.c (working copy)
@@ -1932,7 +1932,6 @@
   const char *full_path;
   apr_hash_t *locks;
   apr_hash_index_t *hi;
- const void *key;
   void *val;
   svn_lock_t *l;
 
@@ -1950,7 +1949,7 @@
   SVN_ERR(svn_ra_svn_write_tuple(conn, pool, "w((!", "success"));
   for (hi = apr_hash_first(pool, locks); hi; hi = apr_hash_next(hi))
     {
- apr_hash_this(hi, &key, NULL, &val);
+ apr_hash_this(hi, NULL, NULL, &val);
       l = val;
       SVN_ERR(write_lock(conn, pool, l));
     }
Index: subversion/libsvn_fs_fs/fs_fs.c
===================================================================
--- subversion/libsvn_fs_fs/fs_fs.c (revision 22603)
+++ subversion/libsvn_fs_fs/fs_fs.c (working copy)
@@ -3968,11 +3968,10 @@
       svn_fs_path_change_t *change;
       const void *key;
       void *val;
- apr_ssize_t keylen;
 
       svn_pool_clear(iterpool);
 
- apr_hash_this(hi, &key, &keylen, &val);
+ apr_hash_this(hi, &key, NULL, &val);
       change = val;
       
       id = change->node_rev_id;

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Dec 8 11:01:00 2006

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