about summary refs log tree commit diff
path: root/compiler/rustc_index/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-01-06 11:54:15 +0000
committerbors <bors@rust-lang.org>2024-01-06 11:54:15 +0000
commitefb3f1108750ab68c855bafd8caffe5d078b6f75 (patch)
tree96ad89b9b640f48b99d0ca7d706dbd097267b5c5 /compiler/rustc_index/src
parente21f4cd98fcf03fb7895f13421699f58132e4beb (diff)
parent0adfe207d7e134fcc130d7bd57a3c6e96f63f8da (diff)
Auto merge of #119499 - cjgillot:dtm-opt, r=nnethercote
Two small bitset optimisations
Diffstat (limited to 'compiler/rustc_index/src')
-rw-r--r--compiler/rustc_index/src/bit_set.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs
index cba02548eb5..dfa3ced9dc1 100644
--- a/compiler/rustc_index/src/bit_set.rs
+++ b/compiler/rustc_index/src/bit_set.rs
@@ -1699,14 +1699,15 @@ impl<R: Idx, C: Idx> BitMatrix<R, C> {
         let (read_start, read_end) = self.range(read);
         let (write_start, write_end) = self.range(write);
         let words = &mut self.words[..];
-        let mut changed = false;
+        let mut changed = 0;
         for (read_index, write_index) in iter::zip(read_start..read_end, write_start..write_end) {
             let word = words[write_index];
             let new_word = word | words[read_index];
             words[write_index] = new_word;
-            changed |= word != new_word;
+            // See `bitwise` for the rationale.
+            changed |= word ^ new_word;
         }
-        changed
+        changed != 0
     }
 
     /// Adds the bits from `with` to the bits from row `write`, and
@@ -1715,14 +1716,7 @@ impl<R: Idx, C: Idx> BitMatrix<R, C> {
         assert!(write.index() < self.num_rows);
         assert_eq!(with.domain_size(), self.num_columns);
         let (write_start, write_end) = self.range(write);
-        let mut changed = false;
-        for (read_index, write_index) in iter::zip(0..with.words.len(), write_start..write_end) {
-            let word = self.words[write_index];
-            let new_word = word | with.words[read_index];
-            self.words[write_index] = new_word;
-            changed |= word != new_word;
-        }
-        changed
+        bitwise(&mut self.words[write_start..write_end], &with.words, |a, b| a | b)
     }
 
     /// Sets every cell in `row` to true.