Skip to content

Commit

Permalink
Update src/librustdoc/html/render/search_index/encode.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
  • Loading branch information
notriddle and GuillaumeGomez committed Apr 2, 2024
1 parent c65f7d8 commit ffaee75
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/librustdoc/html/render/search_index/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,23 @@ impl Container {
r += !chunk & u64::from((chunk << 1).count_ones());
r += !next_chunk & u64::from((chunk >> 63).count_ones());
}
if (2 + 4 * r) < 8192 {
let bits = std::mem::replace(bits, Box::new([0; 1024]));
*self = Container::Run(Vec::new());
for (i, bits) in bits.iter().copied().enumerate() {
if bits == 0 {
continue;
}
for j in 0..64 {
let value = (u16::try_from(i).unwrap() << 6) | j;
if bits & (1 << j) != 0 {
self.push(value);
}
if (2 + 4 * r) >= 8192 {
return false;
}
let bits = std::mem::replace(bits, Box::new([0; 1024]));
*self = Container::Run(Vec::new());
for (i, bits) in bits.iter().copied().enumerate() {
if bits == 0 {
continue;
}
for j in 0..64 {
let value = (u16::try_from(i).unwrap() << 6) | j;
if bits & (1 << j) != 0 {
self.push(value);
}
}
true
} else {
false
}
true
}
Container::Array(array) if array.len() <= 5 => false,
Container::Array(array) => {
Expand Down

0 comments on commit ffaee75

Please sign in to comment.