Merge branch 'sb/histogram-less-memory'
[gitweb.git] / ewah / ewah_bitmap.c
index 3fa3edf2a31e2614b9bb3a18b494d1ec297ab9f7..d59b1afe3d6a83b89dc30e19e61f8a3e9b1cc0aa 100644 (file)
@@ -276,6 +276,18 @@ void ewah_each_bit(struct ewah_bitmap *self, void (*callback)(size_t, void*), vo
        }
 }
 
+/**
+ * Clear all the bits in the bitmap. Does not free or resize
+ * memory.
+ */
+static void ewah_clear(struct ewah_bitmap *self)
+{
+       self->buffer_size = 1;
+       self->buffer[0] = 0;
+       self->bit_size = 0;
+       self->rlw = self->buffer;
+}
+
 struct ewah_bitmap *ewah_new(void)
 {
        struct ewah_bitmap *self;
@@ -288,14 +300,6 @@ struct ewah_bitmap *ewah_new(void)
        return self;
 }
 
-void ewah_clear(struct ewah_bitmap *self)
-{
-       self->buffer_size = 1;
-       self->buffer[0] = 0;
-       self->bit_size = 0;
-       self->rlw = self->buffer;
-}
-
 void ewah_free(struct ewah_bitmap *self)
 {
        if (!self)
@@ -440,75 +444,6 @@ void ewah_xor(
        out->bit_size = max_size(ewah_i->bit_size, ewah_j->bit_size);
 }
 
-void ewah_or(
-       struct ewah_bitmap *ewah_i,
-       struct ewah_bitmap *ewah_j,
-       struct ewah_bitmap *out)
-{
-       struct rlw_iterator rlw_i;
-       struct rlw_iterator rlw_j;
-       size_t literals;
-
-       rlwit_init(&rlw_i, ewah_i);
-       rlwit_init(&rlw_j, ewah_j);
-
-       while (rlwit_word_size(&rlw_i) > 0 && rlwit_word_size(&rlw_j) > 0) {
-               while (rlw_i.rlw.running_len > 0 || rlw_j.rlw.running_len > 0) {
-                       struct rlw_iterator *prey, *predator;
-
-                       if (rlw_i.rlw.running_len < rlw_j.rlw.running_len) {
-                               prey = &rlw_i;
-                               predator = &rlw_j;
-                       } else {
-                               prey = &rlw_j;
-                               predator = &rlw_i;
-                       }
-
-                       if (predator->rlw.running_bit) {
-                               ewah_add_empty_words(out, 0,
-                                       predator->rlw.running_len);
-                               rlwit_discard_first_words(prey,
-                                       predator->rlw.running_len);
-                               rlwit_discard_first_words(predator,
-                                       predator->rlw.running_len);
-                       } else {
-                               size_t index = rlwit_discharge(prey, out,
-                                       predator->rlw.running_len, 0);
-                               ewah_add_empty_words(out, 0,
-                                       predator->rlw.running_len - index);
-                               rlwit_discard_first_words(predator,
-                                       predator->rlw.running_len);
-                       }
-               }
-
-               literals = min_size(
-                       rlw_i.rlw.literal_words,
-                       rlw_j.rlw.literal_words);
-
-               if (literals) {
-                       size_t k;
-
-                       for (k = 0; k < literals; ++k) {
-                               ewah_add(out,
-                                       rlw_i.buffer[rlw_i.literal_word_start + k] |
-                                       rlw_j.buffer[rlw_j.literal_word_start + k]
-                               );
-                       }
-
-                       rlwit_discard_first_words(&rlw_i, literals);
-                       rlwit_discard_first_words(&rlw_j, literals);
-               }
-       }
-
-       if (rlwit_word_size(&rlw_i) > 0)
-               rlwit_discharge(&rlw_i, out, ~0, 0);
-       else
-               rlwit_discharge(&rlw_j, out, ~0, 0);
-
-       out->bit_size = max_size(ewah_i->bit_size, ewah_j->bit_size);
-}
-
-
 #define BITMAP_POOL_MAX 16
 static struct ewah_bitmap *bitmap_pool[BITMAP_POOL_MAX];
 static size_t bitmap_pool_size;