1- use super :: fixed:: { FixedBitfield , FIXED_BITFIELD_BITS_LENGTH , FIXED_BITFIELD_LENGTH } ;
1+ use super :: fixed:: { FIXED_BITFIELD_BITS_LENGTH , FIXED_BITFIELD_LENGTH , FixedBitfield } ;
22use crate :: {
3- common:: { BitfieldUpdate , StoreInfo , StoreInfoInstruction , StoreInfoType } ,
43 Store ,
4+ common:: { BitfieldUpdate , StoreInfo , StoreInfoInstruction , StoreInfoType } ,
55} ;
66use futures:: future:: Either ;
77use std:: { cell:: RefCell , convert:: TryInto } ;
@@ -176,22 +176,22 @@ impl DynamicBitfield {
176176 // not pages that don't exist, as they can't possibly contain the value.
177177
178178 // To keep the common case fast, first try the same page as the position
179- if let Some ( p) = self . pages . get ( first_page) {
180- if let Some ( index) = p. borrow ( ) . index_of ( value, first_index as u32 ) {
181- return Some ( first_page * DYNAMIC_BITFIELD_PAGE_SIZE as u64 + index as u64 ) ;
182- } ;
183- }
179+ if let Some ( p) = self . pages . get ( first_page)
180+ && let Some ( index) = p. borrow ( ) . index_of ( value, first_index as u32 )
181+ {
182+ return Some ( first_page * DYNAMIC_BITFIELD_PAGE_SIZE as u64 + index as u64 ) ;
183+ } ;
184184
185185 // It wasn't found on the first page, now get the keys that are bigger
186186 // than the given index and sort them.
187187 let mut keys: Vec < & u64 > = self . pages . keys ( ) . filter ( |key| * * key > first_page) . collect ( ) ;
188188 keys. sort ( ) ;
189189 for key in keys {
190- if let Some ( p) = self . pages . get ( * key) {
191- if let Some ( index) = p. borrow ( ) . index_of ( value, 0 ) {
192- return Some ( key * DYNAMIC_BITFIELD_PAGE_SIZE as u64 + index as u64 ) ;
193- } ;
194- }
190+ if let Some ( p) = self . pages . get ( * key)
191+ && let Some ( index) = p. borrow ( ) . index_of ( value, 0 )
192+ {
193+ return Some ( key * DYNAMIC_BITFIELD_PAGE_SIZE as u64 + index as u64 ) ;
194+ } ;
195195 }
196196 } else {
197197 // Searching for the false value is easier as it is automatically hit on
@@ -223,11 +223,11 @@ impl DynamicBitfield {
223223 // not pages that don't exist, as they can't possibly contain the value.
224224
225225 // To keep the common case fast, first try the same page as the position
226- if let Some ( p) = self . pages . get ( last_page) {
227- if let Some ( index) = p. borrow ( ) . last_index_of ( value, last_index as u32 ) {
228- return Some ( last_page * DYNAMIC_BITFIELD_PAGE_SIZE as u64 + index as u64 ) ;
229- } ;
230- }
226+ if let Some ( p) = self . pages . get ( last_page)
227+ && let Some ( index) = p. borrow ( ) . last_index_of ( value, last_index as u32 )
228+ {
229+ return Some ( last_page * DYNAMIC_BITFIELD_PAGE_SIZE as u64 + index as u64 ) ;
230+ } ;
231231
232232 // It wasn't found on the last page, now get the keys that are smaller
233233 // than the given index and sort them.
@@ -236,14 +236,13 @@ impl DynamicBitfield {
236236 keys. reverse ( ) ;
237237
238238 for key in keys {
239- if let Some ( p) = self . pages . get ( * key) {
240- if let Some ( index) = p
239+ if let Some ( p) = self . pages . get ( * key)
240+ && let Some ( index) = p
241241 . borrow ( )
242242 . last_index_of ( value, FIXED_BITFIELD_BITS_LENGTH as u32 - 1 )
243- {
244- return Some ( key * DYNAMIC_BITFIELD_PAGE_SIZE as u64 + index as u64 ) ;
245- } ;
246- }
243+ {
244+ return Some ( key * DYNAMIC_BITFIELD_PAGE_SIZE as u64 + index as u64 ) ;
245+ } ;
247246 }
248247 } else {
249248 // Searching for the false value is easier as it is automatically hit on
0 commit comments