message: optimize:replace second loop with bit manipulation
diff: @@ -171,6 +171,13 @@ public:
  entry_idx = row_idx / BITS_PER_VALUE;
  idx_in_entry = row_idx % BITS_PER_VALUE;
  }
  + //! Get an entry that has first-n bits set as valid and rest set as invalid
  + static inline V EntryWithValidBits(idx_t n) {
  + if (n == 0) {
  + return V(0);
  + }
  + return ValidityBuffer::MAX_ENTRY >> (BITS_PER_VALUE - n);
  + }
  //! RowIsValidUnsafe should only be used if AllValid() is false: it achieves the same as RowIsValid but skips a
  //! not-null check
  @@ -246,28 +253,33 @@ public:
  }
  }
  - inline void SetAll(idx_t count, bool valid, V v) {
  + //! Marks exactly "count" bits in the validity mask as invalid (null)
  + inline void SetAllInvalid(idx_t count) {
  + EnsureWritable();
  if (count == 0) {
  return;
  }
  - EnsureWritable();
  - auto entry_count = ValidityBuffer::EntryCount(count);
  - for (idx_t i = 0; i < entry_count - 1; i++) {
  - validity_mask[i] = v;
  - }
  - for (idx_t i = (entry_count - 1) * BITS_PER_VALUE; i < count; i++) {
  - Set(i, valid);
  - }
  + auto last_entry_index = ValidityBuffer::EntryCount(count) - 1;
  + for (idx_t i = 0; i < last_entry_index; i++) {
  + validity_mask[i] = 0;
  }
  -
  - //! Marks exactly "count" bits in the validity mask as invalid (null)
  - inline void SetAllInvalid(idx_t count) {
  - SetAll(count, false, 0);
  + auto last_entry_bits = count % static_cast<idx_t>(BITS_PER_VALUE);
  + validity_mask[last_entry_index] = (last_entry_bits == 0) ? 0 : (ValidityBuffer::MAX_ENTRY << (last_entry_bits));
  }
  //! Marks exactly "count" bits in the validity mask as valid (not null)
  inline void SetAllValid(idx_t count) {
  - SetAll(count, true, ValidityBuffer::MAX_ENTRY);
  + EnsureWritable();
  + if (count == 0) {
  + return;
  + }
  + auto last_entry_index = ValidityBuffer::EntryCount(count) - 1;
  + for (idx_t i = 0; i < last_entry_index; i++) {
  + validity_mask[i] = ValidityBuffer::MAX_ENTRY;
  + }
  + auto last_entry_bits = count % static_cast<idx_t>(BITS_PER_VALUE);
  + validity_mask[last_entry_index] |= (last_entry_bits == 0) ?
  + ValidityBuffer::MAX_ENTRY : ~(ValidityBuffer::MAX_ENTRY << (last_entry_bits));
  }
  inline bool IsMaskSet() const {
  