You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2012/04/12 02:51:42 UTC

[lucy-commits] svn commit: r1325082 - in /lucy/trunk/core/Lucy: Index/FilePurger.c Index/Indexer.c Index/Segment.c Index/Snapshot.c Index/SortFieldWriter.c Object/CharBuf.c Object/CharBuf.cfh Object/VTable.c Store/Folder.c Store/SharedLock.c

Author: marvin
Date: Thu Apr 12 00:51:41 2012
New Revision: 1325082

URL: http://svn.apache.org/viewvc?rev=1325082&view=rev
Log:
Purge EMPTY from the code base.

Modified:
    lucy/trunk/core/Lucy/Index/FilePurger.c
    lucy/trunk/core/Lucy/Index/Indexer.c
    lucy/trunk/core/Lucy/Index/Segment.c
    lucy/trunk/core/Lucy/Index/Snapshot.c
    lucy/trunk/core/Lucy/Index/SortFieldWriter.c
    lucy/trunk/core/Lucy/Object/CharBuf.c
    lucy/trunk/core/Lucy/Object/CharBuf.cfh
    lucy/trunk/core/Lucy/Object/VTable.c
    lucy/trunk/core/Lucy/Store/Folder.c
    lucy/trunk/core/Lucy/Store/SharedLock.c

Modified: lucy/trunk/core/Lucy/Index/FilePurger.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Index/FilePurger.c?rev=1325082&r1=1325081&r2=1325082&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Index/FilePurger.c (original)
+++ lucy/trunk/core/Lucy/Index/FilePurger.c Thu Apr 12 00:51:41 2012
@@ -59,7 +59,7 @@ FilePurger_init(FilePurger *self, Folder
 
     // Don't allow the locks directory to be zapped.
     self->disallowed = Hash_new(0);
-    Hash_Store_Str(self->disallowed, "locks", 5, INCREF(&EMPTY));
+    Hash_Store_Str(self->disallowed, "locks", 5, (Obj*)CFISH_TRUE);
 
     return self;
 }
@@ -96,7 +96,7 @@ FilePurger_purge(FilePurger *self) {
             if (Hash_Fetch(self->disallowed, (Obj*)entry)) { continue; }
             if (!Folder_Delete(folder, entry)) {
                 if (Folder_Exists(folder, entry)) {
-                    Hash_Store(failures, (Obj*)entry, INCREF(&EMPTY));
+                    Hash_Store(failures, (Obj*)entry, (Obj*)CFISH_TRUE);
                 }
             }
         }
@@ -160,12 +160,12 @@ S_zap_dead_merge(FilePurger *self, Hash 
                     THROW(ERR, "Can't open segment dir '%o'", filepath);
                 }
 
-                Hash_Store(candidates, (Obj*)cutoff_seg, INCREF(&EMPTY));
-                Hash_Store(candidates, (Obj*)merge_json, INCREF(&EMPTY));
+                Hash_Store(candidates, (Obj*)cutoff_seg, (Obj*)CFISH_TRUE);
+                Hash_Store(candidates, (Obj*)merge_json, (Obj*)CFISH_TRUE);
                 while (DH_Next(dh)) {
                     // TODO: recursively delete subdirs within seg dir.
                     CB_setf(filepath, "%o/%o", cutoff_seg, entry);
-                    Hash_Store(candidates, (Obj*)filepath, INCREF(&EMPTY));
+                    Hash_Store(candidates, (Obj*)filepath, (Obj*)CFISH_TRUE);
                 }
                 DECREF(filepath);
                 DECREF(dh);
@@ -235,7 +235,7 @@ S_discover_unused(FilePurger *self, VArr
                 // candidates for deletion.
                 for (uint32_t i = 0, max = VA_Get_Size(referenced); i < max; i++) {
                     CharBuf *file = (CharBuf*)VA_Fetch(referenced, i);
-                    Hash_Store(candidates, (Obj*)file, INCREF(&EMPTY));
+                    Hash_Store(candidates, (Obj*)file, (Obj*)CFISH_TRUE);
                 }
                 VA_Push(snapshots, INCREF(snapshot));
             }
@@ -270,12 +270,12 @@ S_find_all_referenced(Folder *folder, VA
     Hash *uniqued = Hash_new(VA_Get_Size(entries));
     for (uint32_t i = 0, max = VA_Get_Size(entries); i < max; i++) {
         CharBuf *entry = (CharBuf*)VA_Fetch(entries, i);
-        Hash_Store(uniqued, (Obj*)entry, INCREF(&EMPTY));
+        Hash_Store(uniqued, (Obj*)entry, (Obj*)CFISH_TRUE);
         if (Folder_Is_Directory(folder, entry)) {
             VArray *contents = Folder_List_R(folder, entry);
             for (uint32_t j = VA_Get_Size(contents); j--;) {
                 CharBuf *sub_entry = (CharBuf*)VA_Fetch(contents, j);
-                Hash_Store(uniqued, (Obj*)sub_entry, INCREF(&EMPTY));
+                Hash_Store(uniqued, (Obj*)sub_entry, (Obj*)CFISH_TRUE);
             }
             DECREF(contents);
         }

Modified: lucy/trunk/core/Lucy/Index/Indexer.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Index/Indexer.c?rev=1325082&r1=1325081&r2=1325082&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Index/Indexer.c (original)
+++ lucy/trunk/core/Lucy/Index/Indexer.c Thu Apr 12 00:51:41 2012
@@ -431,7 +431,7 @@ S_maybe_merge(Indexer *self, VArray *seg
             THROW(ERR, "Recycle() tried to merge segment '%o' twice",
                   seg_name);
         }
-        Hash_Store(seen, (Obj*)seg_name, INCREF(&EMPTY));
+        Hash_Store(seen, (Obj*)seg_name, (Obj*)CFISH_TRUE);
     }
     DECREF(seen);
 

Modified: lucy/trunk/core/Lucy/Index/Segment.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Index/Segment.c?rev=1325082&r1=1325081&r2=1325082&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Index/Segment.c (original)
+++ lucy/trunk/core/Lucy/Index/Segment.c Thu Apr 12 00:51:41 2012
@@ -43,7 +43,7 @@ Seg_init(Segment *self, int64_t number) 
     self->by_name   = Hash_new(0);
 
     // Start field numbers at 1, not 0.
-    VA_Push(self->by_num, INCREF(&EMPTY));
+    VA_Push(self->by_num, (Obj*)CB_newf(""));
 
     // Assign.
     self->number = number;

Modified: lucy/trunk/core/Lucy/Index/Snapshot.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Index/Snapshot.c?rev=1325082&r1=1325081&r2=1325082&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Index/Snapshot.c (original)
+++ lucy/trunk/core/Lucy/Index/Snapshot.c Thu Apr 12 00:51:41 2012
@@ -59,7 +59,7 @@ Snapshot_destroy(Snapshot *self) {
 
 void
 Snapshot_add_entry(Snapshot *self, const CharBuf *entry) {
-    Hash_Store(self->entries, (Obj*)entry, INCREF(&EMPTY));
+    Hash_Store(self->entries, (Obj*)entry, (Obj*)CFISH_TRUE);
 }
 
 bool_t
@@ -132,7 +132,7 @@ Snapshot_read_file(Snapshot *self, Folde
         for (uint32_t i = 0, max = VA_Get_Size(list); i < max; i++) {
             CharBuf *entry
                 = (CharBuf*)CERTIFY(VA_Fetch(list, i), CHARBUF);
-            Hash_Store(self->entries, (Obj*)entry, INCREF(&EMPTY));
+            Hash_Store(self->entries, (Obj*)entry, (Obj*)CFISH_TRUE);
         }
 
         DECREF(list);

Modified: lucy/trunk/core/Lucy/Index/SortFieldWriter.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Index/SortFieldWriter.c?rev=1325082&r1=1325081&r2=1325082&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Index/SortFieldWriter.c (original)
+++ lucy/trunk/core/Lucy/Index/SortFieldWriter.c Thu Apr 12 00:51:41 2012
@@ -172,7 +172,7 @@ S_find_unique_value(Hash *uniq_vals, Obj
     int32_t  hash_sum  = Obj_Hash_Sum(val);
     Obj     *uniq_val  = Hash_Find_Key(uniq_vals, val, hash_sum);
     if (!uniq_val) {
-        Hash_Store(uniq_vals, val, INCREF(&EMPTY));
+        Hash_Store(uniq_vals, val, (Obj*)CFISH_TRUE);
         uniq_val = Hash_Find_Key(uniq_vals, val, hash_sum);
     }
     return uniq_val;
@@ -431,7 +431,7 @@ SortFieldWriter_refill(SortFieldWriter *
           ) {
         Obj *val = SortCache_Value(sort_cache, self->run_ord, blank);
         if (val) {
-            Hash_Store(uniq_vals, val, INCREF(&EMPTY));
+            Hash_Store(uniq_vals, val, (Obj*)CFISH_TRUE);
             break;
         }
         self->run_ord++;

Modified: lucy/trunk/core/Lucy/Object/CharBuf.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Object/CharBuf.c?rev=1325082&r1=1325081&r2=1325082&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Object/CharBuf.c (original)
+++ lucy/trunk/core/Lucy/Object/CharBuf.c Thu Apr 12 00:51:41 2012
@@ -48,8 +48,6 @@ S_die_invalid_utf8(const char *text, siz
 static void
 S_die_invalid_pattern(const char *pattern);
 
-ZombieCharBuf EMPTY = { ZOMBIECHARBUF, {1}, "", 0, 0 };
-
 CharBuf*
 CB_new(size_t size) {
     CharBuf *self = (CharBuf*)VTable_Make_Obj(CHARBUF);

Modified: lucy/trunk/core/Lucy/Object/CharBuf.cfh
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Object/CharBuf.cfh?rev=1325082&r1=1325081&r2=1325082&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Object/CharBuf.cfh (original)
+++ lucy/trunk/core/Lucy/Object/CharBuf.cfh Thu Apr 12 00:51:41 2012
@@ -398,12 +398,9 @@ __C__
 #define CFISH_ZCB_WRAP_STR(ptr, size) \
     lucy_ZCB_wrap_str(alloca(lucy_ZCB_size()), ptr, size)
 
-extern lucy_ZombieCharBuf CFISH_ZCB_EMPTY;
-
 #ifdef LUCY_USE_SHORT_NAMES
   #define ZCB_BLANK             CFISH_ZCB_BLANK
   #define ZCB_LITERAL(_string)  CFISH_ZCB_LITERAL(_string)
-  #define EMPTY                 CFISH_ZCB_EMPTY
   #define ZCB_WRAP              CFISH_ZCB_WRAP
   #define ZCB_WRAP_STR          CFISH_ZCB_WRAP_STR
 #endif

Modified: lucy/trunk/core/Lucy/Object/VTable.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Object/VTable.c?rev=1325082&r1=1325081&r2=1325082&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Object/VTable.c (original)
+++ lucy/trunk/core/Lucy/Object/VTable.c Thu Apr 12 00:51:41 2012
@@ -27,6 +27,7 @@
 #include "Lucy/Object/Err.h"
 #include "Lucy/Object/Hash.h"
 #include "Lucy/Object/LockFreeRegistry.h"
+#include "Lucy/Object/Num.h"
 #include "Lucy/Object/VArray.h"
 #include "Lucy/Util/Atomic.h"
 #include "Lucy/Util/Memory.h"
@@ -159,7 +160,7 @@ VTable_singleton(const CharBuf *class_na
             for (uint32_t i = 0; i < num_fresh; i++) {
                 CharBuf *meth = (CharBuf*)VA_fetch(fresh_host_methods, i);
                 S_scrunch_charbuf(meth, scrunched);
-                Hash_Store(meths, (Obj*)scrunched, INCREF(&EMPTY));
+                Hash_Store(meths, (Obj*)scrunched, (Obj*)CFISH_TRUE);
             }
             cfish_Callback **callbacks
                 = (cfish_Callback**)singleton->callbacks;

Modified: lucy/trunk/core/Lucy/Store/Folder.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Store/Folder.c?rev=1325082&r1=1325081&r2=1325082&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Store/Folder.c (original)
+++ lucy/trunk/core/Lucy/Store/Folder.c Thu Apr 12 00:51:41 2012
@@ -250,7 +250,14 @@ S_add_to_file_list(Folder *self, VArray 
 DirHandle*
 Folder_open_dir(Folder *self, const CharBuf *path) {
     DirHandle *dh = NULL;
-    Folder *folder = Folder_Find_Folder(self, path ? path : (CharBuf*)&EMPTY);
+    Folder *folder;
+    if (path) {
+        folder = Folder_Find_Folder(self, path);
+    }
+    else {
+        ZombieCharBuf *empty = ZCB_BLANK();
+        folder = Folder_Find_Folder(self, (CharBuf*)empty);
+    }
     if (!folder) {
         Err_set_error(Err_new(CB_newf("Invalid path: '%o'", path)));
     }

Modified: lucy/trunk/core/Lucy/Store/SharedLock.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Store/SharedLock.c?rev=1325082&r1=1325081&r2=1325082&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Store/SharedLock.c (original)
+++ lucy/trunk/core/Lucy/Store/SharedLock.c Thu Apr 12 00:51:41 2012
@@ -40,7 +40,7 @@ ShLock_init(SharedLock *self, Folder *fo
 
     // Override.
     DECREF(self->lock_path);
-    self->lock_path = (CharBuf*)INCREF(&EMPTY);
+    self->lock_path = CB_newf("");
 
     return self;
 }
@@ -57,8 +57,9 @@ ShLock_request(SharedLock *self) {
     ShLock_request_t super_request
         = (ShLock_request_t)SUPER_METHOD(SHAREDLOCK, ShLock, Request);
 
-    // EMPTY lock_path indicates whether this particular instance is locked.
-    if (self->lock_path != (CharBuf*)&EMPTY
+    // Empty lock_path indicates whether this particular instance is locked.
+    if (self->lock_path
+        && !CB_Equals_Str(self->lock_path, "", 0)
         && Folder_Exists(self->folder, self->lock_path)
        ) {
         // Don't allow double obtain.
@@ -80,14 +81,14 @@ ShLock_request(SharedLock *self) {
 
 void
 ShLock_release(SharedLock *self) {
-    if (self->lock_path != (CharBuf*)&EMPTY) {
+    if (self->lock_path && !CB_Equals_Str(self->lock_path, "", 0)) {
         ShLock_release_t super_release
             = (ShLock_release_t)SUPER_METHOD(SHAREDLOCK, ShLock, Release);
         super_release(self);
 
         // Empty out lock_path.
         DECREF(self->lock_path);
-        self->lock_path = (CharBuf*)INCREF(&EMPTY);
+        self->lock_path = CB_newf("");
     }
 }