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/09/07 18:53:28 UTC

[lucy-commits] [07/20] git commit: refs/heads/cfish-string-prep1 - Eliminate SStr_Chop in IndexManager

Eliminate SStr_Chop in IndexManager


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

Branch: refs/heads/cfish-string-prep1
Commit: f374f95b57fe279ec688d8f7318b6d75c407fbd4
Parents: 414375f
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Sep 7 14:41:51 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Sep 7 18:14:04 2013 +0200

----------------------------------------------------------------------
 core/Lucy/Index/IndexManager.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/f374f95b/core/Lucy/Index/IndexManager.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/IndexManager.c b/core/Lucy/Index/IndexManager.c
index e2a8009..b1b29b4 100644
--- a/core/Lucy/Index/IndexManager.c
+++ b/core/Lucy/Index/IndexManager.c
@@ -304,7 +304,6 @@ IxManager_Remove_Merge_Data_IMP(IndexManager *self) {
 Lock*
 IxManager_Make_Snapshot_Read_Lock_IMP(IndexManager *self,
                                       const String *filename) {
-    StackString *lock_name = SSTR_WRAP(filename);
     LockFactory *lock_factory = S_obtain_lock_factory(self);
 
     if (!Str_Starts_With_Str(filename, "snapshot_", 9)
@@ -314,9 +313,13 @@ IxManager_Make_Snapshot_Read_Lock_IMP(IndexManager *self,
     }
 
     // Truncate ".json" from end of snapshot file name.
-    SStr_Chop(lock_name, sizeof(".json") - 1);
+    size_t lock_name_len = Str_Length(filename) - (sizeof(".json") - 1);
+    String *lock_name = Str_SubString(filename, 0, lock_name_len);
 
-    return LockFact_Make_Shared_Lock(lock_factory, (String*)lock_name, 1000, 100);
+    Lock *lock = LockFact_Make_Shared_Lock(lock_factory, lock_name, 1000, 100);
+
+    DECREF(lock_name);
+    return lock;
 }
 
 void