lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [08/20] git commit: refs/heads/cfish-string-prep1 - Eliminate SStr_Nip in CompoundFileReader
Date Sat, 07 Sep 2013 16:53:29 GMT
Eliminate SStr_Nip in CompoundFileReader


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

Branch: refs/heads/cfish-string-prep1
Commit: fd388fc1a7474f6f1af82d11cc0fe66e66d1c371
Parents: c7e1875
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sat Sep 7 15:24:00 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sat Sep 7 18:14:04 2013 +0200

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


http://git-wip-us.apache.org/repos/asf/lucy/blob/fd388fc1/core/Lucy/Store/CompoundFileReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/CompoundFileReader.c b/core/Lucy/Store/CompoundFileReader.c
index 3955cfb..cc08f68 100644
--- a/core/Lucy/Store/CompoundFileReader.c
+++ b/core/Lucy/Store/CompoundFileReader.c
@@ -87,7 +87,6 @@ CFReader_do_open(CompoundFileReader *self, Folder *folder) {
     // Strip directory name from filepaths for old format.
     if (ivars->format == 1) {
         VArray *files = Hash_Keys(ivars->records);
-        StackString *filename = SStr_BLANK();
         StackString *folder_name
             = IxFileNames_local_part(Folder_Get_Path(folder), SStr_BLANK());
         size_t folder_name_len = SStr_Length(folder_name);
@@ -96,9 +95,11 @@ CFReader_do_open(CompoundFileReader *self, Folder *folder) {
             String *orig = (String*)VA_Fetch(files, i);
             if (Str_Starts_With(orig, (String*)folder_name)) {
                 Obj *record = Hash_Delete(ivars->records, (Obj*)orig);
-                SStr_Assign(filename, orig);
-                SStr_Nip(filename, folder_name_len + sizeof(DIR_SEP) - 1);
+                size_t offset = folder_name_len + sizeof(DIR_SEP) - 1;
+                size_t len    = Str_Length(orig) - offset;
+                String *filename = Str_SubString(orig, offset, len);
                 Hash_Store(ivars->records, (Obj*)filename, (Obj*)record);
+                DECREF(filename);
             }
         }
 


Mime
View raw message