@@ -18,15 +18,15 @@ pub struct TermWeight {
1818}
1919
2020enum TermOrEmptyOrAllScorer {
21- TermScorer ( TermScorer ) ,
21+ TermScorer ( Box < TermScorer > ) ,
2222 Empty ,
2323 AllMatch ( AllScorer ) ,
2424}
2525
2626impl TermOrEmptyOrAllScorer {
2727 pub fn into_boxed_scorer ( self ) -> Box < dyn Scorer > {
2828 match self {
29- TermOrEmptyOrAllScorer :: TermScorer ( scorer) => Box :: new ( scorer) ,
29+ TermOrEmptyOrAllScorer :: TermScorer ( scorer) => scorer,
3030 TermOrEmptyOrAllScorer :: Empty => Box :: new ( EmptyScorer ) ,
3131 TermOrEmptyOrAllScorer :: AllMatch ( scorer) => Box :: new ( scorer) ,
3232 }
@@ -48,9 +48,7 @@ impl Weight for TermWeight {
4848 explanation. add_context ( format ! ( "Term={:?}" , self . term, ) ) ;
4949 Ok ( explanation)
5050 }
51- TermOrEmptyOrAllScorer :: Empty => {
52- return Err ( does_not_match ( doc) ) ;
53- }
51+ TermOrEmptyOrAllScorer :: Empty => Err ( does_not_match ( doc) ) ,
5452 TermOrEmptyOrAllScorer :: AllMatch ( _) => AllWeight . explain ( reader, doc) ,
5553 }
5654 }
@@ -75,7 +73,7 @@ impl Weight for TermWeight {
7573 ) -> crate :: Result < ( ) > {
7674 match self . specialized_scorer ( reader, 1.0 ) ? {
7775 TermOrEmptyOrAllScorer :: TermScorer ( mut term_scorer) => {
78- for_each_scorer ( & mut term_scorer, callback) ;
76+ for_each_scorer ( & mut * term_scorer, callback) ;
7977 }
8078 TermOrEmptyOrAllScorer :: Empty => { }
8179 TermOrEmptyOrAllScorer :: AllMatch ( mut all_scorer) => {
@@ -127,7 +125,7 @@ impl Weight for TermWeight {
127125 match specialized_scorer {
128126 TermOrEmptyOrAllScorer :: TermScorer ( term_scorer) => {
129127 crate :: query:: boolean_query:: block_wand_single_scorer (
130- term_scorer,
128+ * term_scorer,
131129 threshold,
132130 callback,
133131 ) ;
@@ -173,7 +171,7 @@ impl TermWeight {
173171 ) -> crate :: Result < Option < TermScorer > > {
174172 let scorer = self . specialized_scorer ( reader, boost) ?;
175173 Ok ( match scorer {
176- TermOrEmptyOrAllScorer :: TermScorer ( scorer) => Some ( scorer) ,
174+ TermOrEmptyOrAllScorer :: TermScorer ( scorer) => Some ( * scorer) ,
177175 _ => None ,
178176 } )
179177 }
@@ -203,10 +201,8 @@ impl TermWeight {
203201
204202 let fieldnorm_reader = self . fieldnorm_reader ( reader) ?;
205203 let similarity_weight = self . similarity_weight . boost_by ( boost) ;
206- Ok ( TermOrEmptyOrAllScorer :: TermScorer ( TermScorer :: new (
207- segment_postings,
208- fieldnorm_reader,
209- similarity_weight,
204+ Ok ( TermOrEmptyOrAllScorer :: TermScorer ( Box :: new (
205+ TermScorer :: new ( segment_postings, fieldnorm_reader, similarity_weight) ,
210206 ) ) )
211207 }
212208
0 commit comments