You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2013/08/26 00:57:14 UTC

[lucy-commits] [12/14] git commit: refs/heads/cfish-string-prep1 - Eliminate CB_setf/CB_catf in Store::Folder

Eliminate CB_setf/CB_catf in Store::Folder


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/de6d7a3a
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/de6d7a3a
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/de6d7a3a

Branch: refs/heads/cfish-string-prep1
Commit: de6d7a3aa59cd9d859da46a4014491afc55ccd34
Parents: 07f5886
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Aug 25 22:26:33 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Mon Aug 26 00:54:48 2013 +0200

----------------------------------------------------------------------
 core/Lucy/Store/Folder.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/de6d7a3a/core/Lucy/Store/Folder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/Folder.c b/core/Lucy/Store/Folder.c
index a0012e1..c032fb5 100644
--- a/core/Lucy/Store/Folder.c
+++ b/core/Lucy/Store/Folder.c
@@ -211,8 +211,8 @@ S_is_updir(CharBuf *path) {
 }
 
 static void
-S_add_to_file_list(Folder *self, VArray *list, CharBuf *dir, CharBuf *prefix) {
-    size_t     orig_prefix_size = CB_Get_Size(prefix);
+S_add_to_file_list(Folder *self, VArray *list, CharBuf *dir,
+                   const CharBuf *path) {
     DirHandle *dh = Folder_Open_Dir(self, dir);
     CharBuf   *entry;
 
@@ -223,7 +223,9 @@ S_add_to_file_list(Folder *self, VArray *list, CharBuf *dir, CharBuf *prefix) {
     entry = DH_Get_Entry(dh);
     while (DH_Next(dh)) { // Updates entry
         if (!S_is_updir(entry)) {
-            CharBuf *relpath = CB_newf("%o%o", prefix, entry);
+            CharBuf *relpath = path && CB_Get_Size(path)
+                               ? CB_newf("%o/%o", path, entry)
+                               : CB_Clone(entry);
             if (VA_Get_Size(list) == VA_Get_Capacity(list)) {
                 VA_Grow(list, VA_Get_Size(list) * 2);
             }
@@ -233,9 +235,7 @@ S_add_to_file_list(Folder *self, VArray *list, CharBuf *dir, CharBuf *prefix) {
                 CharBuf *subdir = CB_Get_Size(dir)
                                   ? CB_newf("%o/%o", dir, entry)
                                   : CB_Clone(entry);
-                CB_catf(prefix, "%o/", entry);
-                S_add_to_file_list(self, list, subdir, prefix); // recurse
-                CB_Set_Size(prefix, orig_prefix_size);
+                S_add_to_file_list(self, list, subdir, relpath); // recurse
                 DECREF(subdir);
             }
         }
@@ -342,12 +342,7 @@ Folder_List_R_IMP(Folder *self, const CharBuf *path) {
     VArray *list =  VA_new(0);
     if (local_folder) {
         CharBuf *dir    = CB_new(20);
-        CharBuf *prefix = CB_new(20);
-        if (path && CB_Get_Size(path)) {
-            CB_setf(prefix, "%o/", path);
-        }
-        S_add_to_file_list(local_folder, list, dir, prefix);
-        DECREF(prefix);
+        S_add_to_file_list(local_folder, list, dir, path);
         DECREF(dir);
     }
     return list;