patch around non-exported return type

This commit is contained in:
Cary Sandvig 2022-12-22 15:11:36 -05:00
parent a2aa8af973
commit 89e27ad9db
3 changed files with 18 additions and 10 deletions

View File

@ -177,15 +177,15 @@ extract(int low_bit, int size) const {
if (b + size < num_bits_per_word) {
// The whole thing fits within one word of the array.
return get_word(w).extract(b, size);
return get_word_internal(w).extract(b, size);
} else {
// We have to split it across two words.
int num_lower_bits = num_bits_per_word - b;
int num_higher_bits = size - num_lower_bits;
return get_word(w).extract(b, num_lower_bits) |
(get_word(w + 1).extract(0, num_higher_bits) << num_lower_bits);
return get_word_internal(w).extract(b, num_lower_bits) |
(get_word_internal(w + 1).extract(0, num_higher_bits) << num_lower_bits);
}
}
@ -241,17 +241,24 @@ get_num_words() const {
* get_num_words(), but the return value beyond get_num_words() will always be
* the same.
*/
INLINE BitArray::MaskType BitArray::
INLINE BitArray::WordType BitArray::
get_word(size_t n) const {
return get_word_internal(n).get_word();
}
/**
* Internal implementation of get_word that returns MaskType.
*/
INLINE BitArray::MaskType BitArray::
get_word_internal(size_t n) const {
nassertr(n >= 0, MaskType::all_off());
if (n < get_num_words()) {
return _array[n];
}
if (_highest_bits) {
return MaskType::all_on();
} else {
return MaskType::all_off();
}
return MaskType::all_off();
}
/**

View File

@ -103,7 +103,7 @@ has_any_of(int low_bit, int size) const {
}
if (b + size <= num_bits_per_word) {
// The whole thing fits within one word of the array.
return get_word(w).has_any_of(b, size);
return get_word_internal(w).has_any_of(b, size);
}
int num_high_bits = num_bits_per_word - b;
@ -156,7 +156,7 @@ has_all_of(int low_bit, int size) const {
}
if (b + size <= num_bits_per_word) {
// The whole thing fits within one word of the array.
return get_word(w).has_all_of(b, size);
return get_word_internal(w).has_all_of(b, size);
}
int num_high_bits = num_bits_per_word - b;
@ -588,7 +588,7 @@ compare_to(const BitArray &other) const {
// Compare from highest-order to lowest-order word.
for (int i = num_words - 1; i >= 0; --i) {
int compare = get_word(i).compare_to(other.get_word(i));
int compare = get_word_internal(i).compare_to(other.get_word_internal(i));
if (compare != 0) {
return compare;
}

View File

@ -89,7 +89,7 @@ PUBLISHED:
int get_next_higher_different_bit(int low_bit) const;
INLINE size_t get_num_words() const;
INLINE MaskType get_word(size_t n) const;
INLINE WordType get_word(size_t n) const;
INLINE void set_word(size_t n, WordType value);
void invert_in_place();
@ -140,6 +140,7 @@ public:
void generate_hash(ChecksumHashGenerator &hashgen) const;
private:
INLINE MaskType get_word_internal(size_t n) const;
INLINE void copy_on_write();
void ensure_has_word(int n);
void normalize();