From b36c3134bb1a292aa63b219ad97d3be93caa7015 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 15 Jun 2018 18:27:38 +0000 Subject: [PATCH 01/10] ewah/bitmap.c: delete unused 'bitmap_clear()' Reported-by: Ramsay Jones Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- ewah/bitmap.c | 8 -------- ewah/ewok.h | 1 - 2 files changed, 9 deletions(-) diff --git a/ewah/bitmap.c b/ewah/bitmap.c index 756bdd050e..d61dc6114a 100644 --- a/ewah/bitmap.c +++ b/ewah/bitmap.c @@ -45,14 +45,6 @@ void bitmap_set(struct bitmap *self, size_t pos) self->words[block] |= EWAH_MASK(pos); } -void bitmap_clear(struct bitmap *self, size_t pos) -{ - size_t block = EWAH_BLOCK(pos); - - if (block < self->word_alloc) - self->words[block] &= ~EWAH_MASK(pos); -} - int bitmap_get(struct bitmap *self, size_t pos) { size_t block = EWAH_BLOCK(pos); diff --git a/ewah/ewok.h b/ewah/ewok.h index 357fd93c84..8714585333 100644 --- a/ewah/ewok.h +++ b/ewah/ewok.h @@ -204,7 +204,6 @@ struct bitmap { struct bitmap *bitmap_new(void); void bitmap_set(struct bitmap *self, size_t pos); -void bitmap_clear(struct bitmap *self, size_t pos); int bitmap_get(struct bitmap *self, size_t pos); void bitmap_reset(struct bitmap *self); void bitmap_free(struct bitmap *self); From 48dc98344facad88ccb954ebdd8440b8ca501800 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 15 Jun 2018 18:27:41 +0000 Subject: [PATCH 02/10] ewah/bitmap.c: delete unused 'bitmap_each_bit()' Reported-by: Ramsay Jones Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- ewah/bitmap.c | 24 ------------------------ ewah/ewok.h | 1 - 2 files changed, 25 deletions(-) diff --git a/ewah/bitmap.c b/ewah/bitmap.c index d61dc6114a..52f1178db4 100644 --- a/ewah/bitmap.c +++ b/ewah/bitmap.c @@ -129,30 +129,6 @@ void bitmap_or_ewah(struct bitmap *self, struct ewah_bitmap *other) self->words[i++] |= word; } -void bitmap_each_bit(struct bitmap *self, ewah_callback callback, void *data) -{ - size_t pos = 0, i; - - for (i = 0; i < self->word_alloc; ++i) { - eword_t word = self->words[i]; - uint32_t offset; - - if (word == (eword_t)~0) { - for (offset = 0; offset < BITS_IN_EWORD; ++offset) - callback(pos++, data); - } else { - for (offset = 0; offset < BITS_IN_EWORD; ++offset) { - if ((word >> offset) == 0) - break; - - offset += ewah_bit_ctz64(word >> offset); - callback(pos + offset, data); - } - pos += BITS_IN_EWORD; - } - } -} - size_t bitmap_popcount(struct bitmap *self) { size_t i, count = 0; diff --git a/ewah/ewok.h b/ewah/ewok.h index 8714585333..7c04e6e356 100644 --- a/ewah/ewok.h +++ b/ewah/ewok.h @@ -217,7 +217,6 @@ void bitmap_and_not(struct bitmap *self, struct bitmap *other); void bitmap_or_ewah(struct bitmap *self, struct ewah_bitmap *other); void bitmap_or(struct bitmap *self, const struct bitmap *other); -void bitmap_each_bit(struct bitmap *self, ewah_callback callback, void *data); size_t bitmap_popcount(struct bitmap *self); #endif From 01b4a63f5563c84e557f2e071f91418bf8be4f9e Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 15 Jun 2018 18:27:44 +0000 Subject: [PATCH 03/10] ewah_bitmap: delete unused 'ewah_and()' Reported-by: Ramsay Jones Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- ewah/ewah_bitmap.c | 68 ---------------------------------------------- ewah/ewok.h | 5 ---- 2 files changed, 73 deletions(-) diff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c index b9fdda1d3d..5a4d3a6eb6 100644 --- a/ewah/ewah_bitmap.c +++ b/ewah/ewah_bitmap.c @@ -459,74 +459,6 @@ void ewah_xor( out->bit_size = max_size(ewah_i->bit_size, ewah_j->bit_size); } -void ewah_and( - 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 == 0) { - 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_empty(&rlw_i, out); - else - rlwit_discharge_empty(&rlw_j, out); - - out->bit_size = max_size(ewah_i->bit_size, ewah_j->bit_size); -} - void ewah_and_not( struct ewah_bitmap *ewah_i, struct ewah_bitmap *ewah_j, diff --git a/ewah/ewok.h b/ewah/ewok.h index 7c04e6e356..1476bd18ba 100644 --- a/ewah/ewok.h +++ b/ewah/ewok.h @@ -179,11 +179,6 @@ void ewah_xor( struct ewah_bitmap *ewah_j, struct ewah_bitmap *out); -void ewah_and( - struct ewah_bitmap *ewah_i, - struct ewah_bitmap *ewah_j, - struct ewah_bitmap *out); - /** * Direct word access */ From 19436fe03a5822c0588fbc99d9e3ab8a5f1301cf Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 15 Jun 2018 18:27:46 +0000 Subject: [PATCH 04/10] ewah_bitmap: delete unused 'ewah_and_not()' Reported-by: Ramsay Jones Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- ewah/ewah_bitmap.c | 73 ---------------------------------------------- ewah/ewok.h | 5 ---- 2 files changed, 78 deletions(-) diff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c index 5a4d3a6eb6..559adde37c 100644 --- a/ewah/ewah_bitmap.c +++ b/ewah/ewah_bitmap.c @@ -459,79 +459,6 @@ void ewah_xor( out->bit_size = max_size(ewah_i->bit_size, ewah_j->bit_size); } -void ewah_and_not( - 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 && prey == &rlw_i) || - (!predator->rlw.running_bit && prey != &rlw_i)) { - 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; - int negate_words; - - negate_words = (&rlw_i != prey); - index = rlwit_discharge(prey, out, - predator->rlw.running_len, negate_words); - ewah_add_empty_words(out, negate_words, - 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_empty(&rlw_j, out); - - 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, diff --git a/ewah/ewok.h b/ewah/ewok.h index 1476bd18ba..0ee0c70217 100644 --- a/ewah/ewok.h +++ b/ewah/ewok.h @@ -169,11 +169,6 @@ void ewah_or( struct ewah_bitmap *ewah_j, struct ewah_bitmap *out); -void ewah_and_not( - struct ewah_bitmap *ewah_i, - struct ewah_bitmap *ewah_j, - struct ewah_bitmap *out); - void ewah_xor( struct ewah_bitmap *ewah_i, struct ewah_bitmap *ewah_j, From 44301d2b76bd32074fcdbf97c51264ca2149c513 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 15 Jun 2018 18:27:48 +0000 Subject: [PATCH 05/10] ewah_bitmap: delete unused 'ewah_not()' Reported-by: Ramsay Jones Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- ewah/ewah_bitmap.c | 19 ------------------- ewah/ewok.h | 7 ------- 2 files changed, 26 deletions(-) diff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c index 559adde37c..3fa3edf2a3 100644 --- a/ewah/ewah_bitmap.c +++ b/ewah/ewah_bitmap.c @@ -376,25 +376,6 @@ void ewah_iterator_init(struct ewah_iterator *it, struct ewah_bitmap *parent) read_new_rlw(it); } -void ewah_not(struct ewah_bitmap *self) -{ - size_t pointer = 0; - - while (pointer < self->buffer_size) { - eword_t *word = &self->buffer[pointer]; - size_t literals, k; - - rlw_xor_run_bit(word); - ++pointer; - - literals = rlw_get_literal_words(word); - for (k = 0; k < literals; ++k) { - self->buffer[pointer] = ~self->buffer[pointer]; - ++pointer; - } - } -} - void ewah_xor( struct ewah_bitmap *ewah_i, struct ewah_bitmap *ewah_j, diff --git a/ewah/ewok.h b/ewah/ewok.h index 0ee0c70217..a603fa3dd8 100644 --- a/ewah/ewok.h +++ b/ewah/ewok.h @@ -95,13 +95,6 @@ ssize_t ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len); uint32_t ewah_checksum(struct ewah_bitmap *self); -/** - * Logical not (bitwise negation) in-place on the bitmap - * - * This operation is linear time based on the size of the bitmap. - */ -void ewah_not(struct ewah_bitmap *self); - /** * Call the given callback with the position of every single bit * that has been set on the bitmap. From a9fda811fc39b69c5763c17e732ddbe7c779c4eb Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 15 Jun 2018 18:27:50 +0000 Subject: [PATCH 06/10] ewah_bitmap: delete unused 'ewah_or()' Reported-by: Ramsay Jones Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- ewah/ewah_bitmap.c | 69 ---------------------------------------------- ewah/ewok.h | 5 ---- 2 files changed, 74 deletions(-) diff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c index 3fa3edf2a3..017c677f98 100644 --- a/ewah/ewah_bitmap.c +++ b/ewah/ewah_bitmap.c @@ -440,75 +440,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; diff --git a/ewah/ewok.h b/ewah/ewok.h index a603fa3dd8..cf902e50ad 100644 --- a/ewah/ewok.h +++ b/ewah/ewok.h @@ -157,11 +157,6 @@ void ewah_iterator_init(struct ewah_iterator *it, struct ewah_bitmap *parent); */ int ewah_iterator_next(eword_t *next, struct ewah_iterator *it); -void ewah_or( - struct ewah_bitmap *ewah_i, - struct ewah_bitmap *ewah_j, - struct ewah_bitmap *out); - void ewah_xor( struct ewah_bitmap *ewah_i, struct ewah_bitmap *ewah_j, From 83ea4e1e5997898ee98eacc61fce56cc1c614cd4 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 15 Jun 2018 18:27:52 +0000 Subject: [PATCH 07/10] ewah_io: delete unused 'ewah_serialize()' Reported-by: Ramsay Jones Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- ewah/ewah_io.c | 10 ---------- ewah/ewok.h | 1 - 2 files changed, 11 deletions(-) diff --git a/ewah/ewah_io.c b/ewah/ewah_io.c index 33c08c40f8..345ee6287e 100644 --- a/ewah/ewah_io.c +++ b/ewah/ewah_io.c @@ -100,16 +100,6 @@ int ewah_serialize_to(struct ewah_bitmap *self, return (3 * 4) + (self->buffer_size * 8); } -static int write_helper(void *fd, const void *buf, size_t len) -{ - return write((intptr_t)fd, buf, len); -} - -int ewah_serialize(struct ewah_bitmap *self, int fd) -{ - return ewah_serialize_to(self, write_helper, (void *)(intptr_t)fd); -} - static int write_strbuf(void *user_data, const void *data, size_t len) { struct strbuf *sb = user_data; diff --git a/ewah/ewok.h b/ewah/ewok.h index cf902e50ad..894f0dc5fd 100644 --- a/ewah/ewok.h +++ b/ewah/ewok.h @@ -86,7 +86,6 @@ void ewah_free(struct ewah_bitmap *self); int ewah_serialize_to(struct ewah_bitmap *self, int (*write_fun)(void *out, const void *buf, size_t len), void *out); -int ewah_serialize(struct ewah_bitmap *self, int fd); int ewah_serialize_native(struct ewah_bitmap *self, int fd); int ewah_serialize_strbuf(struct ewah_bitmap *self, struct strbuf *); From caa88140d4cc9e0ac79bb5d9d6569fe7d08a93a8 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 14 Jun 2018 23:31:58 -0400 Subject: [PATCH 08/10] ewah: drop ewah_deserialize function We don't call this function, and in fact never have since it was added (at least not in iterations of the ewah patches that got merged). Instead we use ewah_read_mmap(). Let's drop the unused code. Note to anybody who later wants to resurrect this: it does not check for integer overflow in the ewah data size, meaning it may be possible to convince the code to allocate a too-small buffer and read() into it. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- ewah/ewah_io.c | 55 -------------------------------------------------- ewah/ewok.h | 1 - 2 files changed, 56 deletions(-) diff --git a/ewah/ewah_io.c b/ewah/ewah_io.c index 345ee6287e..5e8fa9ebfc 100644 --- a/ewah/ewah_io.c +++ b/ewah/ewah_io.c @@ -158,58 +158,3 @@ ssize_t ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len) return ptr - (const uint8_t *)map; } - -int ewah_deserialize(struct ewah_bitmap *self, int fd) -{ - size_t i; - eword_t dump[2048]; - const size_t words_per_dump = sizeof(dump) / sizeof(eword_t); - uint32_t bitsize, word_count, rlw_pos; - - eword_t *buffer = NULL; - size_t words_left; - - ewah_clear(self); - - /* 32 bit -- bit size for the map */ - if (read(fd, &bitsize, 4) != 4) - return -1; - - self->bit_size = (size_t)ntohl(bitsize); - - /** 32 bit -- number of compressed 64-bit words */ - if (read(fd, &word_count, 4) != 4) - return -1; - - self->buffer_size = self->alloc_size = (size_t)ntohl(word_count); - REALLOC_ARRAY(self->buffer, self->alloc_size); - - /** 64 bit x N -- compressed words */ - buffer = self->buffer; - words_left = self->buffer_size; - - while (words_left >= words_per_dump) { - if (read(fd, dump, sizeof(dump)) != sizeof(dump)) - return -1; - - for (i = 0; i < words_per_dump; ++i, ++buffer) - *buffer = ntohll(dump[i]); - - words_left -= words_per_dump; - } - - if (words_left) { - if (read(fd, dump, words_left * 8) != words_left * 8) - return -1; - - for (i = 0; i < words_left; ++i, ++buffer) - *buffer = ntohll(dump[i]); - } - - /** 32 bit -- position for the RLW */ - if (read(fd, &rlw_pos, 4) != 4) - return -1; - - self->rlw = self->buffer + ntohl(rlw_pos); - return 0; -} diff --git a/ewah/ewok.h b/ewah/ewok.h index 894f0dc5fd..e32a09cb27 100644 --- a/ewah/ewok.h +++ b/ewah/ewok.h @@ -89,7 +89,6 @@ int ewah_serialize_to(struct ewah_bitmap *self, int ewah_serialize_native(struct ewah_bitmap *self, int fd); int ewah_serialize_strbuf(struct ewah_bitmap *self, struct strbuf *); -int ewah_deserialize(struct ewah_bitmap *self, int fd); ssize_t ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len); uint32_t ewah_checksum(struct ewah_bitmap *self); From 26675087a58e1e7dd54bc0f059ad2f831c6e3fbf Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 14 Jun 2018 23:32:28 -0400 Subject: [PATCH 09/10] ewah: drop ewah_serialize_native function We don't call this function, and never have. The on-disk bitmap format uses network-byte-order integers, meaning that we cannot use the native-byte-order format written here. Let's drop it in the name of simplicity. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- ewah/ewah_io.c | 26 -------------------------- ewah/ewok.h | 1 - 2 files changed, 27 deletions(-) diff --git a/ewah/ewah_io.c b/ewah/ewah_io.c index 5e8fa9ebfc..9035ee65ea 100644 --- a/ewah/ewah_io.c +++ b/ewah/ewah_io.c @@ -20,32 +20,6 @@ #include "ewok.h" #include "strbuf.h" -int ewah_serialize_native(struct ewah_bitmap *self, int fd) -{ - uint32_t write32; - size_t to_write = self->buffer_size * 8; - - /* 32 bit -- bit size for the map */ - write32 = (uint32_t)self->bit_size; - if (write(fd, &write32, 4) != 4) - return -1; - - /** 32 bit -- number of compressed 64-bit words */ - write32 = (uint32_t)self->buffer_size; - if (write(fd, &write32, 4) != 4) - return -1; - - if (write(fd, self->buffer, to_write) != to_write) - return -1; - - /** 32 bit -- position for the RLW */ - write32 = self->rlw - self->buffer; - if (write(fd, &write32, 4) != 4) - return -1; - - return (3 * 4) + to_write; -} - int ewah_serialize_to(struct ewah_bitmap *self, int (*write_fun)(void *, const void *, size_t), void *data) diff --git a/ewah/ewok.h b/ewah/ewok.h index e32a09cb27..0c504f28e2 100644 --- a/ewah/ewok.h +++ b/ewah/ewok.h @@ -86,7 +86,6 @@ void ewah_free(struct ewah_bitmap *self); int ewah_serialize_to(struct ewah_bitmap *self, int (*write_fun)(void *out, const void *buf, size_t len), void *out); -int ewah_serialize_native(struct ewah_bitmap *self, int fd); int ewah_serialize_strbuf(struct ewah_bitmap *self, struct strbuf *); ssize_t ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len); From c806278e0c7c0e0de5b32d013676326221b86c35 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 19 Jun 2018 22:51:20 +0100 Subject: [PATCH 10/10] ewah: delete unused 'rlwit_discharge_empty()' Complete the removal of unused 'ewah bitmap' code by removing the now unused 'rlwit_discharge_empty()' function. Also, the 'ewah_clear()' function can now be made a file-scope static symbol. Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano --- ewah/ewah_bitmap.c | 20 ++++++++++++-------- ewah/ewah_rlw.c | 8 -------- ewah/ewok.h | 6 ------ ewah/ewok_rlw.h | 1 - 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c index 017c677f98..d59b1afe3d 100644 --- a/ewah/ewah_bitmap.c +++ b/ewah/ewah_bitmap.c @@ -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) diff --git a/ewah/ewah_rlw.c b/ewah/ewah_rlw.c index b9643b7d0f..5093d43e2f 100644 --- a/ewah/ewah_rlw.c +++ b/ewah/ewah_rlw.c @@ -104,11 +104,3 @@ size_t rlwit_discharge( return index; } - -void rlwit_discharge_empty(struct rlw_iterator *it, struct ewah_bitmap *out) -{ - while (rlwit_word_size(it) > 0) { - ewah_add_empty_words(out, 0, rlwit_word_size(it)); - rlwit_discard_first_words(it, rlwit_word_size(it)); - } -} diff --git a/ewah/ewok.h b/ewah/ewok.h index 0c504f28e2..84b2a29faa 100644 --- a/ewah/ewok.h +++ b/ewah/ewok.h @@ -72,12 +72,6 @@ void ewah_pool_free(struct ewah_bitmap *self); */ struct ewah_bitmap *ewah_new(void); -/** - * Clear all the bits in the bitmap. Does not free or resize - * memory. - */ -void ewah_clear(struct ewah_bitmap *self); - /** * Free all the memory of the bitmap */ diff --git a/ewah/ewok_rlw.h b/ewah/ewok_rlw.h index bb3c6ff7e0..7cdfdd0c02 100644 --- a/ewah/ewok_rlw.h +++ b/ewah/ewok_rlw.h @@ -98,7 +98,6 @@ void rlwit_init(struct rlw_iterator *it, struct ewah_bitmap *bitmap); void rlwit_discard_first_words(struct rlw_iterator *it, size_t x); size_t rlwit_discharge( struct rlw_iterator *it, struct ewah_bitmap *out, size_t max, int negate); -void rlwit_discharge_empty(struct rlw_iterator *it, struct ewah_bitmap *out); static inline size_t rlwit_word_size(struct rlw_iterator *it) {