// Index(begin) ... Index(end) // [xxxxx???][........][????yyyy] // ^ ^ // | #---- Bit of visit_end // #---- Bit of visit_begin //
// Left edge.
uintptr_t left_edge = bitmap_begin_[index_start]; // Clear the lower bits that are not in range.
left_edge &= ~((static_cast<uintptr_t>(1) << (bit_start % kBitsPerBitmapWord)) - 1);
// Right edge. Either unique, or left_edge.
uintptr_t right_edge;
if (index_start < index_end) { // Left edge != right edge.
// Traverse left edge. if (left_edge != 0) { const uintptr_t ptr_base = WordIndexToBitIndex(index_start); do { const size_t shift = CTZ(left_edge);
visitor(ptr_base + shift);
left_edge ^= static_cast<uintptr_t>(1) << shift;
} while (left_edge != 0);
}
// Traverse the middle, full part. for (size_t i = index_start + 1; i < index_end; ++i) {
uintptr_t w = bitmap_begin_[i]; if (w != 0) { const uintptr_t ptr_base = WordIndexToBitIndex(i); do { const size_t shift = CTZ(w);
visitor(ptr_base + shift);
w ^= static_cast<uintptr_t>(1) << shift;
} while (w != 0);
}
}
// Right edge is unique. // But maybe we don't have anything to do: visit_end starts in a new word... if (bit_end == 0) { // Do not read memory, as it could be after the end of the bitmap.
right_edge = 0;
} else {
right_edge = bitmap_begin_[index_end];
}
} else {
right_edge = left_edge;
}
// Right edge handling.
right_edge &= ((static_cast<uintptr_t>(1) << (bit_end % kBitsPerBitmapWord)) - 1); if (right_edge != 0) { const uintptr_t ptr_base = WordIndexToBitIndex(index_end); do { const size_t shift = CTZ(right_edge);
visitor(ptr_base + shift);
right_edge ^= (static_cast<uintptr_t>(1)) << shift;
} while (right_edge != 0);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.