@@ -5,7 +5,7 @@ use std::collections::BTreeMap;
55use std:: collections:: HashSet ;
66use std:: io:: Cursor ;
77use std:: rc:: Rc ;
8- use std:: { self , mem , str} ;
8+ use std:: { self , str} ;
99
1010use self :: varint:: VarintRead ;
1111
@@ -314,15 +314,15 @@ impl ExactMatchFilter {
314314
315315 if let Some ( ( key, value) ) = self . iter . next ( ) {
316316 debug_assert ! ( key. starts_with( value_key. as_bytes( ) ) ) ; // must always be true!
317- if let JsonValue :: String ( string) = JsonFetcher :: bytes_to_json_value ( & * value) {
317+ if let JsonValue :: String ( string) = JsonFetcher :: bytes_to_json_value ( & value) {
318318 let matches = if self . case_sensitive {
319319 self . phrase == string
320320 } else {
321321 self . phrase == string. to_lowercase ( )
322322 } ;
323323 if matches {
324- if self . term_ordinal . is_some ( ) {
325- dr. add_score ( self . term_ordinal . unwrap ( ) , 1.0 ) ;
324+ if let Some ( to ) = self . term_ordinal {
325+ dr. add_score ( to , 1.0 ) ;
326326 }
327327 return Some ( dr) ;
328328 } else {
@@ -444,16 +444,16 @@ impl QueryRuntimeFilter for RangeFilter {
444444 || self . min == Some ( RangeOperator :: Null )
445445 {
446446 let mut dr = KeyBuilder :: parse_doc_result_from_kp_word_key ( key_str) ;
447- if self . term_ordinal . is_some ( ) {
448- dr. add_score ( self . term_ordinal . unwrap ( ) , 1.0 ) ;
447+ if let Some ( to ) = self . term_ordinal {
448+ dr. add_score ( to , 1.0 ) ;
449449 }
450450 return Some ( dr) ;
451451 }
452452 // Else it's a range query on numbers
453453
454454 let number = unsafe {
455455 let array = * ( value[ ..] . as_ptr ( ) as * const [ _ ; 8 ] ) ;
456- mem :: transmute :: < [ u8 ; 8 ] , f64 > ( array)
456+ f64 :: from_ne_bytes ( array)
457457 } ;
458458
459459 let min_condition = match self . min {
@@ -473,8 +473,8 @@ impl QueryRuntimeFilter for RangeFilter {
473473
474474 if min_condition && max_condition {
475475 let mut dr = KeyBuilder :: parse_doc_result_from_kp_word_key ( key_str) ;
476- if self . term_ordinal . is_some ( ) {
477- dr. add_score ( self . term_ordinal . unwrap ( ) , 1.0 ) ;
476+ if let Some ( to ) = self . term_ordinal {
477+ dr. add_score ( to , 1.0 ) ;
478478 }
479479 return Some ( dr) ;
480480 }
@@ -538,9 +538,7 @@ impl<'a> BboxFilter<'a> {
538538
539539impl < ' a > QueryRuntimeFilter for BboxFilter < ' a > {
540540 fn first_result ( & mut self , start : & DocResult ) -> Option < DocResult > {
541- let query = self
542- . kb
543- . rtree_query_key ( start. seq , std:: u64:: MAX , & self . bbox ) ;
541+ let query = self . kb . rtree_query_key ( start. seq , u64:: MAX , & self . bbox ) ;
544542 self . iter = Some ( self . snapshot . new_rtree_iterator ( & query) ) ;
545543 self . next_result ( )
546544 }
@@ -556,14 +554,14 @@ impl<'a> QueryRuntimeFilter for BboxFilter<'a> {
556554
557555 let iid = unsafe {
558556 let array = * ( key[ offset + key_len as usize ..] . as_ptr ( ) as * const [ _ ; 8 ] ) ;
559- mem :: transmute :: < [ u8 ; 8 ] , u64 > ( array)
557+ u64 :: from_ne_bytes ( array)
560558 } ;
561559
562560 let mut dr = DocResult :: new ( ) ;
563561 dr. seq = iid;
564562 dr. arraypath = BboxFilter :: from_u8_slice ( & value) ;
565- if self . term_ordinal . is_some ( ) {
566- dr. add_score ( self . term_ordinal . unwrap ( ) , 1.0 ) ;
563+ if let Some ( to ) = self . term_ordinal {
564+ dr. add_score ( to , 1.0 ) ;
567565 }
568566 Some ( dr)
569567 } else {
@@ -828,32 +826,22 @@ impl<'a> FilterWithResult<'a> {
828826 if self . result . is_none ( ) || self . result . as_ref ( ) . unwrap ( ) . less ( start, self . array_depth ) {
829827 self . result = self . filter . first_result ( start) ;
830828 }
831- if self . result . is_none ( ) {
832- self . is_done = true ;
833- } else {
834- self . result
835- . as_mut ( )
836- . unwrap ( )
837- . arraypath
838- . resize ( self . array_depth , 0 ) ;
829+ match self . result . as_mut ( ) {
830+ Some ( result) => result. arraypath . resize ( self . array_depth , 0 ) ,
831+ None => self . is_done = true ,
839832 }
840833 }
841834
842835 fn prime_next_result ( & mut self ) {
843836 if self . is_done {
844837 return ;
845838 }
846- if self . result . is_none ( ) {
847- self . result = self . filter . next_result ( ) ;
848- }
849- if self . result . is_none ( ) {
850- self . is_done = true ;
851- } else {
852- self . result
853- . as_mut ( )
854- . unwrap ( )
855- . arraypath
856- . resize ( self . array_depth , 0 ) ;
839+ match self . result . as_mut ( ) {
840+ Some ( result) => result. arraypath . resize ( self . array_depth , 0 ) ,
841+ None => {
842+ self . is_done = true ;
843+ self . result = self . filter . next_result ( ) ;
844+ }
857845 }
858846 }
859847}
0 commit comments