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 2012/04/14 16:06:08 UTC
[lucy-commits] svn commit: r1326109 - in /lucy/trunk/core: Lucy.c Lucy/Object/Hash.c
Lucy/Object/Hash.cfh
Author: nwellnhof
Date: Sat Apr 14 14:06:07 2012
New Revision: 1326109
URL: http://svn.apache.org/viewvc?rev=1326109&view=rev
Log:
Create HashTombStone during run-time
Modified:
lucy/trunk/core/Lucy.c
lucy/trunk/core/Lucy/Object/Hash.c
lucy/trunk/core/Lucy/Object/Hash.cfh
Modified: lucy/trunk/core/Lucy.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy.c?rev=1326109&r1=1326108&r2=1326109&view=diff
==============================================================================
--- lucy/trunk/core/Lucy.c (original)
+++ lucy/trunk/core/Lucy.c Sat Apr 14 14:06:07 2012
@@ -15,9 +15,11 @@
*/
#include "Lucy/Object/Num.h"
+#include "Lucy/Object/Hash.h"
void
lucy_init_parcel() {
lucy_Bool_init_class();
+ lucy_Hash_init_class();
}
Modified: lucy/trunk/core/Lucy/Object/Hash.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Object/Hash.c?rev=1326109&r1=1326108&r2=1326109&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Object/Hash.c (original)
+++ lucy/trunk/core/Lucy/Object/Hash.c Sat Apr 14 14:06:07 2012
@@ -33,10 +33,7 @@
#include "Lucy/Util/Freezer.h"
#include "Lucy/Util/Memory.h"
-static HashTombStone TOMBSTONE = {
- HASHTOMBSTONE,
- {1}
-};
+static HashTombStone *TOMBSTONE;
#define HashEntry lucy_HashEntry
@@ -58,6 +55,11 @@ SI_fetch_entry(Hash *self, const Obj *ke
static INLINE HashEntry*
SI_rebuild_hash(Hash *self);
+void
+Hash_init_class() {
+ TOMBSTONE = (HashTombStone*)VTable_Make_Obj(HASHTOMBSTONE);
+}
+
Hash*
Hash_new(uint32_t capacity) {
Hash *self = (Hash*)VTable_Make_Obj(HASH);
@@ -259,8 +261,8 @@ Hash_do_store(Hash *self, Obj *key, Obj
while (1) {
tick &= mask;
HashEntry *entry = entries + tick;
- if (entry->key == (Obj*)&TOMBSTONE || !entry->key) {
- if (entry->key == (Obj*)&TOMBSTONE) {
+ if (entry->key == (Obj*)TOMBSTONE || !entry->key) {
+ if (entry->key == (Obj*)TOMBSTONE) {
// Take note of diminished tombstone clutter.
self->threshold++;
}
@@ -342,7 +344,7 @@ Hash_delete(Hash *self, const Obj *key)
if (entry) {
Obj *value = entry->value;
DECREF(entry->key);
- entry->key = (Obj*)&TOMBSTONE;
+ entry->key = (Obj*)TOMBSTONE;
entry->value = NULL;
entry->hash_sum = 0;
self->size--;
@@ -384,7 +386,7 @@ Hash_next(Hash *self, Obj **key, Obj **v
else {
HashEntry *const entry
= (HashEntry*)self->entries + self->iter_tick;
- if (entry->key && entry->key != (Obj*)&TOMBSTONE) {
+ if (entry->key && entry->key != (Obj*)TOMBSTONE) {
// Success!
*key = entry->key;
*value = entry->value;
@@ -464,7 +466,7 @@ SI_rebuild_hash(Hash *self) {
self->size = 0;
for (; entry < limit; entry++) {
- if (!entry->key || entry->key == (Obj*)&TOMBSTONE) {
+ if (!entry->key || entry->key == (Obj*)TOMBSTONE) {
continue;
}
Hash_do_store(self, entry->key, entry->value,
Modified: lucy/trunk/core/Lucy/Object/Hash.cfh
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Object/Hash.cfh?rev=1326109&r1=1326108&r2=1326109&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Object/Hash.cfh (original)
+++ lucy/trunk/core/Lucy/Object/Hash.cfh Sat Apr 14 14:06:07 2012
@@ -32,6 +32,9 @@ class Lucy::Object::Hash inherits Lucy::
uint32_t threshold; /* rehashing trigger point */
int32_t iter_tick; /* used when iterating */
+ inert void
+ init_class();
+
inert incremented Hash*
new(uint32_t capacity = 0);