| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #include "vm/bit_vector.h" |
| 6 |
| 7 #include "vm/os.h" |
| 8 |
| 9 namespace dart { |
| 10 |
| 11 #ifdef DEBUG |
| 12 void BitVector::Print() { |
| 13 bool first = true; |
| 14 OS::Print("{"); |
| 15 for (int i = 0; i < length(); i++) { |
| 16 if (Contains(i)) { |
| 17 if (!first) OS::Print(","); |
| 18 first = false; |
| 19 OS::Print("%d", i); |
| 20 } |
| 21 } |
| 22 OS::Print("}"); |
| 23 } |
| 24 #endif |
| 25 |
| 26 |
| 27 void BitVector::Iterator::Advance() { |
| 28 ++bit_index_; |
| 29 // Skip zero words. |
| 30 if (current_word_ == 0) { |
| 31 do { |
| 32 ++word_index_; |
| 33 if (Done()) return; |
| 34 current_word_ = target_->data_[word_index_]; |
| 35 } while (current_word_ == 0); |
| 36 bit_index_ = current_word_ * sizeof(uword); |
| 37 } |
| 38 // Skip zero bytes. |
| 39 while ((current_word_ & 0xff) == 0) { |
| 40 current_word_ >>= 8; |
| 41 bit_index_ += 8; |
| 42 } |
| 43 // Skip zero bits. |
| 44 while ((current_word_ & 0x1) == 0) { |
| 45 current_word_ >>= 1; |
| 46 ++bit_index_; |
| 47 } |
| 48 current_word_ = current_word_ >> 1; |
| 49 } |
| 50 |
| 51 |
| 52 } // namespace dart |
| OLD | NEW |