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:07 UTC

[lucy-commits] [05/14] git commit: refs/heads/cfish-string-prep1 - Eliminate CB_setf in Store::SharedLock

Eliminate CB_setf in Store::SharedLock


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

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

----------------------------------------------------------------------
 core/Lucy/Store/SharedLock.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/ef8c1892/core/Lucy/Store/SharedLock.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/SharedLock.c b/core/Lucy/Store/SharedLock.c
index 420076f..2ec1226 100644
--- a/core/Lucy/Store/SharedLock.c
+++ b/core/Lucy/Store/SharedLock.c
@@ -70,10 +70,9 @@ ShLock_Request_IMP(SharedLock *self) {
         return false;
     }
 
-    DECREF(ivars->lock_path);
-    ivars->lock_path = CB_new(CB_Get_Size(ivars->name) + 10);
     do {
-        CB_setf(ivars->lock_path, "locks/%o-%u32.lock", ivars->name, ++i);
+        DECREF(ivars->lock_path);
+        ivars->lock_path = CB_newf("locks/%o-%u32.lock", ivars->name, ++i);
     } while (Folder_Exists(ivars->folder, ivars->lock_path));
 
     bool success = super_request(self);
@@ -101,7 +100,6 @@ ShLock_Clear_Stale_IMP(SharedLock *self) {
     SharedLockIVARS *const ivars = ShLock_IVARS(self);
     DirHandle *dh;
     CharBuf   *entry;
-    CharBuf   *candidate = NULL;
     CharBuf   *lock_dir_name = (CharBuf*)ZCB_WRAP_STR("locks", 5);
 
     if (Folder_Find_Folder(ivars->folder, lock_dir_name)) {
@@ -118,13 +116,12 @@ ShLock_Clear_Stale_IMP(SharedLock *self) {
         if (CB_Starts_With(entry, ivars->name)
             && CB_Ends_With_Str(entry, ".lock", 5)
            ) {
-            candidate = candidate ? candidate : CB_new(0);
-            CB_setf(candidate, "%o/%o", lock_dir_name, entry);
+            CharBuf *candidate = CB_newf("%o/%o", lock_dir_name, entry);
             ShLock_Maybe_Delete_File(self, candidate, false, true);
+            DECREF(candidate);
         }
     }
 
-    DECREF(candidate);
     DECREF(dh);
 }