1051 return Ok(vec![]); |
1051 return Ok(vec![]); |
1052 } |
1052 } |
1053 |
1053 |
1054 let revisions: Vec<Revision> = as_set.into_iter().collect(); |
1054 let revisions: Vec<Revision> = as_set.into_iter().collect(); |
1055 |
1055 |
1056 if revisions.len() <= 63 { |
1056 if revisions.len() < 8 { |
|
1057 self.find_gca_candidates::<u8>(&revisions) |
|
1058 } else if revisions.len() < 64 { |
1057 self.find_gca_candidates::<u64>(&revisions) |
1059 self.find_gca_candidates::<u64>(&revisions) |
1058 } else { |
1060 } else { |
1059 self.find_gca_candidates::<NonStaticPoisonableBitSet>(&revisions) |
1061 self.find_gca_candidates::<NonStaticPoisonableBitSet>(&revisions) |
1060 } |
1062 } |
1061 } |
1063 } |
1312 /// of integers |
1314 /// of integers |
1313 fn is_full_range(&self, n: usize) -> bool; |
1315 fn is_full_range(&self, n: usize) -> bool; |
1314 } |
1316 } |
1315 |
1317 |
1316 const U64_POISON: u64 = 1 << 63; |
1318 const U64_POISON: u64 = 1 << 63; |
|
1319 const U8_POISON: u8 = 1 << 7; |
1317 |
1320 |
1318 impl PoisonableBitSet for u64 { |
1321 impl PoisonableBitSet for u64 { |
1319 fn vec_of_empty(_sets_size: usize, vec_len: usize) -> Vec<Self> { |
1322 fn vec_of_empty(_sets_size: usize, vec_len: usize) -> Vec<Self> { |
1320 vec![0u64; vec_len] |
1323 vec![0u64; vec_len] |
1321 } |
1324 } |
1356 |
1359 |
1357 fn is_poisoned(&self) -> bool { |
1360 fn is_poisoned(&self) -> bool { |
1358 // equality comparison would be tempting but would not resist |
1361 // equality comparison would be tempting but would not resist |
1359 // operations after poisoning (even if these should be bogus). |
1362 // operations after poisoning (even if these should be bogus). |
1360 *self >= U64_POISON |
1363 *self >= U64_POISON |
|
1364 } |
|
1365 } |
|
1366 |
|
1367 impl PoisonableBitSet for u8 { |
|
1368 fn vec_of_empty(_sets_size: usize, vec_len: usize) -> Vec<Self> { |
|
1369 vec![0; vec_len] |
|
1370 } |
|
1371 |
|
1372 fn size(&self) -> usize { |
|
1373 1 |
|
1374 } |
|
1375 |
|
1376 fn capacity(&self) -> usize { |
|
1377 7 |
|
1378 } |
|
1379 |
|
1380 fn add(&mut self, n: usize) { |
|
1381 (*self) |= 1 << n; |
|
1382 } |
|
1383 |
|
1384 fn discard(&mut self, n: usize) { |
|
1385 (*self) &= u8::MAX - (1 << n); |
|
1386 } |
|
1387 |
|
1388 fn union(&mut self, other: &Self) { |
|
1389 if *self != *other { |
|
1390 (*self) |= *other; |
|
1391 } |
|
1392 } |
|
1393 |
|
1394 fn is_full_range(&self, n: usize) -> bool { |
|
1395 *self + 1 == (1 << n) |
|
1396 } |
|
1397 |
|
1398 fn is_empty(&self) -> bool { |
|
1399 *self == 0 |
|
1400 } |
|
1401 |
|
1402 fn poison(&mut self) { |
|
1403 *self = U8_POISON; |
|
1404 } |
|
1405 |
|
1406 fn is_poisoned(&self) -> bool { |
|
1407 // equality comparison would be tempting but would not resist |
|
1408 // operations after poisoning (even if these should be bogus). |
|
1409 *self >= U8_POISON |
1361 } |
1410 } |
1362 } |
1411 } |
1363 |
1412 |
1364 /// A poisonable bit set whose capacity is not known at compile time but |
1413 /// A poisonable bit set whose capacity is not known at compile time but |
1365 /// is constant after initial construction |
1414 /// is constant after initial construction |