ewah: use less generic macro name

The ewah/ewok.h header pollutes the global namespace with
"BITS_IN_WORD", without any specific notion that we are
talking about the bits in an eword_t. We can give this the
more specific name "BITS_IN_EWORD".

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2015-06-03 02:39:37 -04:00 коммит произвёл Junio C Hamano
Родитель 414382fb00
Коммит 34b935c01f
4 изменённых файлов: 23 добавлений и 23 удалений

Просмотреть файл

@ -20,8 +20,8 @@
#include "git-compat-util.h" #include "git-compat-util.h"
#include "ewok.h" #include "ewok.h"
#define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_WORD)) #define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_EWORD))
#define EWAH_BLOCK(x) (x / BITS_IN_WORD) #define EWAH_BLOCK(x) (x / BITS_IN_EWORD)
struct bitmap *bitmap_new(void) struct bitmap *bitmap_new(void)
{ {
@ -127,7 +127,7 @@ void bitmap_and_not(struct bitmap *self, struct bitmap *other)
void bitmap_or_ewah(struct bitmap *self, struct ewah_bitmap *other) void bitmap_or_ewah(struct bitmap *self, struct ewah_bitmap *other)
{ {
size_t original_size = self->word_alloc; size_t original_size = self->word_alloc;
size_t other_final = (other->bit_size / BITS_IN_WORD) + 1; size_t other_final = (other->bit_size / BITS_IN_EWORD) + 1;
size_t i = 0; size_t i = 0;
struct ewah_iterator it; struct ewah_iterator it;
eword_t word; eword_t word;
@ -155,17 +155,17 @@ void bitmap_each_bit(struct bitmap *self, ewah_callback callback, void *data)
uint32_t offset; uint32_t offset;
if (word == (eword_t)~0) { if (word == (eword_t)~0) {
for (offset = 0; offset < BITS_IN_WORD; ++offset) for (offset = 0; offset < BITS_IN_EWORD; ++offset)
callback(pos++, data); callback(pos++, data);
} else { } else {
for (offset = 0; offset < BITS_IN_WORD; ++offset) { for (offset = 0; offset < BITS_IN_EWORD; ++offset) {
if ((word >> offset) == 0) if ((word >> offset) == 0)
break; break;
offset += ewah_bit_ctz64(word >> offset); offset += ewah_bit_ctz64(word >> offset);
callback(pos + offset, data); callback(pos + offset, data);
} }
pos += BITS_IN_WORD; pos += BITS_IN_EWORD;
} }
} }
} }

Просмотреть файл

@ -102,7 +102,7 @@ size_t ewah_add_empty_words(struct ewah_bitmap *self, int v, size_t number)
if (number == 0) if (number == 0)
return 0; return 0;
self->bit_size += number * BITS_IN_WORD; self->bit_size += number * BITS_IN_EWORD;
return add_empty_words(self, v, number); return add_empty_words(self, v, number);
} }
@ -152,7 +152,7 @@ void ewah_add_dirty_words(
self->buffer_size += can_add; self->buffer_size += can_add;
} }
self->bit_size += can_add * BITS_IN_WORD; self->bit_size += can_add * BITS_IN_EWORD;
if (number - can_add == 0) if (number - can_add == 0)
break; break;
@ -197,7 +197,7 @@ static size_t add_empty_word(struct ewah_bitmap *self, int v)
size_t ewah_add(struct ewah_bitmap *self, eword_t word) size_t ewah_add(struct ewah_bitmap *self, eword_t word)
{ {
self->bit_size += BITS_IN_WORD; self->bit_size += BITS_IN_EWORD;
if (word == 0) if (word == 0)
return add_empty_word(self, 0); return add_empty_word(self, 0);
@ -211,8 +211,8 @@ size_t ewah_add(struct ewah_bitmap *self, eword_t word)
void ewah_set(struct ewah_bitmap *self, size_t i) void ewah_set(struct ewah_bitmap *self, size_t i)
{ {
const size_t dist = const size_t dist =
(i + BITS_IN_WORD) / BITS_IN_WORD - (i + BITS_IN_EWORD) / BITS_IN_EWORD -
(self->bit_size + BITS_IN_WORD - 1) / BITS_IN_WORD; (self->bit_size + BITS_IN_EWORD - 1) / BITS_IN_EWORD;
assert(i >= self->bit_size); assert(i >= self->bit_size);
@ -222,19 +222,19 @@ void ewah_set(struct ewah_bitmap *self, size_t i)
if (dist > 1) if (dist > 1)
add_empty_words(self, 0, dist - 1); add_empty_words(self, 0, dist - 1);
add_literal(self, (eword_t)1 << (i % BITS_IN_WORD)); add_literal(self, (eword_t)1 << (i % BITS_IN_EWORD));
return; return;
} }
if (rlw_get_literal_words(self->rlw) == 0) { if (rlw_get_literal_words(self->rlw) == 0) {
rlw_set_running_len(self->rlw, rlw_set_running_len(self->rlw,
rlw_get_running_len(self->rlw) - 1); rlw_get_running_len(self->rlw) - 1);
add_literal(self, (eword_t)1 << (i % BITS_IN_WORD)); add_literal(self, (eword_t)1 << (i % BITS_IN_EWORD));
return; return;
} }
self->buffer[self->buffer_size - 1] |= self->buffer[self->buffer_size - 1] |=
((eword_t)1 << (i % BITS_IN_WORD)); ((eword_t)1 << (i % BITS_IN_EWORD));
/* check if we just completed a stream of 1s */ /* check if we just completed a stream of 1s */
if (self->buffer[self->buffer_size - 1] == (eword_t)(~0)) { if (self->buffer[self->buffer_size - 1] == (eword_t)(~0)) {
@ -255,11 +255,11 @@ void ewah_each_bit(struct ewah_bitmap *self, void (*callback)(size_t, void*), vo
eword_t *word = &self->buffer[pointer]; eword_t *word = &self->buffer[pointer];
if (rlw_get_run_bit(word)) { if (rlw_get_run_bit(word)) {
size_t len = rlw_get_running_len(word) * BITS_IN_WORD; size_t len = rlw_get_running_len(word) * BITS_IN_EWORD;
for (k = 0; k < len; ++k, ++pos) for (k = 0; k < len; ++k, ++pos)
callback(pos, payload); callback(pos, payload);
} else { } else {
pos += rlw_get_running_len(word) * BITS_IN_WORD; pos += rlw_get_running_len(word) * BITS_IN_EWORD;
} }
++pointer; ++pointer;
@ -268,7 +268,7 @@ void ewah_each_bit(struct ewah_bitmap *self, void (*callback)(size_t, void*), vo
int c; int c;
/* todo: zero count optimization */ /* todo: zero count optimization */
for (c = 0; c < BITS_IN_WORD; ++c, ++pos) { for (c = 0; c < BITS_IN_EWORD; ++c, ++pos) {
if ((self->buffer[pointer] & ((eword_t)1 << c)) != 0) if ((self->buffer[pointer] & ((eword_t)1 << c)) != 0)
callback(pos, payload); callback(pos, payload);
} }

Просмотреть файл

@ -31,7 +31,7 @@
#endif #endif
typedef uint64_t eword_t; typedef uint64_t eword_t;
#define BITS_IN_WORD (sizeof(eword_t) * 8) #define BITS_IN_EWORD (sizeof(eword_t) * 8)
/** /**
* Do not use __builtin_popcountll. The GCC implementation * Do not use __builtin_popcountll. The GCC implementation

Просмотреть файл

@ -618,7 +618,7 @@ static void show_objects_for_type(
while (i < objects->word_alloc && ewah_iterator_next(&filter, &it)) { while (i < objects->word_alloc && ewah_iterator_next(&filter, &it)) {
eword_t word = objects->words[i] & filter; eword_t word = objects->words[i] & filter;
for (offset = 0; offset < BITS_IN_WORD; ++offset) { for (offset = 0; offset < BITS_IN_EWORD; ++offset) {
const unsigned char *sha1; const unsigned char *sha1;
struct revindex_entry *entry; struct revindex_entry *entry;
uint32_t hash = 0; uint32_t hash = 0;
@ -640,7 +640,7 @@ static void show_objects_for_type(
show_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset); show_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset);
} }
pos += BITS_IN_WORD; pos += BITS_IN_EWORD;
i++; i++;
} }
} }
@ -772,7 +772,7 @@ int reuse_partial_packfile_from_bitmap(struct packed_git **packfile,
break; break;
} }
reuse_objects += BITS_IN_WORD; reuse_objects += BITS_IN_EWORD;
} }
#ifdef GIT_BITMAP_DEBUG #ifdef GIT_BITMAP_DEBUG
@ -995,7 +995,7 @@ static int rebuild_bitmap(uint32_t *reposition,
while (ewah_iterator_next(&word, &it)) { while (ewah_iterator_next(&word, &it)) {
uint32_t offset, bit_pos; uint32_t offset, bit_pos;
for (offset = 0; offset < BITS_IN_WORD; ++offset) { for (offset = 0; offset < BITS_IN_EWORD; ++offset) {
if ((word >> offset) == 0) if ((word >> offset) == 0)
break; break;
@ -1008,7 +1008,7 @@ static int rebuild_bitmap(uint32_t *reposition,
return -1; return -1;
} }
pos += BITS_IN_WORD; pos += BITS_IN_EWORD;
} }
return 0; return 0;
} }