Browse Source

fix set_range(), clear_range()

David Rose 20 years ago
parent
commit
b342a22c2f
1 changed files with 13 additions and 1 deletions
  1. 13 1
      panda/src/putil/bitArray.cxx

+ 13 - 1
panda/src/putil/bitArray.cxx

@@ -66,6 +66,12 @@ set_range(int low_bit, int size) {
     return;
     return;
   }
   }
 
 
+  ensure_has_word(w);
+  int num_high_bits = num_bits_per_word - b;
+  _array[w].set_range(b, num_high_bits);
+  size -= num_high_bits;
+  ++w;
+
   while (size > 0) {
   while (size > 0) {
     if (size <= num_bits_per_word) {
     if (size <= num_bits_per_word) {
       // The remainder fits within one word of the array.
       // The remainder fits within one word of the array.
@@ -112,6 +118,12 @@ clear_range(int low_bit, int size) {
     return;
     return;
   }
   }
 
 
+  ensure_has_word(w);
+  int num_high_bits = num_bits_per_word - b;
+  _array[w].clear_range(b, num_high_bits);
+  size -= num_high_bits;
+  ++w;
+
   while (size > 0) {
   while (size > 0) {
     if (size <= num_bits_per_word) {
     if (size <= num_bits_per_word) {
       // The remainder fits within one word of the array.
       // The remainder fits within one word of the array.
@@ -123,7 +135,7 @@ clear_range(int low_bit, int size) {
 
 
     // Keep going.
     // Keep going.
     ensure_has_word(w);
     ensure_has_word(w);
-    _array[w] = MaskType::all_on();
+    _array[w] = MaskType::all_off();
     size -= num_bits_per_word;
     size -= num_bits_per_word;
     ++w;
     ++w;