11use crate :: {
22 imp:: { AuthMeta , Constraints , HostMeta , Meta } ,
3- pct_enc:: { self , encoder:: * , Encoder , Table } ,
3+ pct_enc:: { self , encoder:: * , Encoder } ,
44 utf8,
55} ;
66use core:: {
@@ -166,31 +166,37 @@ impl<'a> Reader<'a> {
166166
167167 // FIXME: This makes things faster but causes significant bloat.
168168 #[ inline( always) ]
169- fn read_generic < const ALLOW_PCT_ENCODED : bool , const ALLOW_NON_ASCII : bool > (
170- & mut self ,
171- table : Table ,
172- ) -> Result < bool > {
169+ fn read < E : Encoder > ( & mut self ) -> Result < bool > {
170+ struct Helper < E : Encoder > {
171+ _marker : PhantomData < E > ,
172+ }
173+
174+ impl < E : Encoder > Helper < E > {
175+ const ALLOWS_PCT_ENCODED : bool = E :: TABLE . allows_pct_encoded ( ) ;
176+ const ALLOWS_NON_ASCII : bool = E :: TABLE . allows_non_ascii ( ) ;
177+ }
178+
173179 let start = self . pos ;
174180 let mut i = self . pos ;
175181
176182 while i < self . len ( ) {
177183 let x = self . bytes [ i] ;
178- if ALLOW_PCT_ENCODED && x == b'%' {
184+ if Helper :: < E > :: ALLOWS_PCT_ENCODED && x == b'%' {
179185 let [ hi, lo, ..] = self . bytes [ i + 1 ..] else {
180186 return self . invalid_pct ( ) ;
181187 } ;
182188 if !pct_enc:: is_hexdig_pair ( hi, lo) {
183189 return self . invalid_pct ( ) ;
184190 }
185191 i += 3 ;
186- } else if ALLOW_NON_ASCII {
192+ } else if Helper :: < E > :: ALLOWS_NON_ASCII {
187193 let ( x, len) = utf8:: next_code_point ( self . bytes , i) ;
188- if !table . allows_code_point ( x) {
194+ if !E :: TABLE . allows_code_point ( x) {
189195 break ;
190196 }
191197 i += len;
192198 } else {
193- if !table . allows_ascii ( x) {
199+ if !E :: TABLE . allows_ascii ( x) {
194200 break ;
195201 }
196202 i += 1 ;
@@ -202,29 +208,6 @@ impl<'a> Reader<'a> {
202208 Ok ( self . pos > start)
203209 }
204210
205- #[ inline( always) ]
206- fn read < E : Encoder > ( & mut self ) -> Result < bool > {
207- struct Helper < E : Encoder > {
208- _marker : PhantomData < E > ,
209- }
210-
211- impl < E : Encoder > Helper < E > {
212- const ALLOWS_PCT_ENCODED : bool = E :: TABLE . allows_pct_encoded ( ) ;
213- const ALLOWS_NON_ASCII : bool = E :: TABLE . allows_non_ascii ( ) ;
214- }
215-
216- if Helper :: < E > :: ALLOWS_PCT_ENCODED {
217- if Helper :: < E > :: ALLOWS_NON_ASCII {
218- self . read_generic :: < true , true > ( E :: TABLE )
219- } else {
220- self . read_generic :: < true , false > ( E :: TABLE )
221- }
222- } else {
223- assert ! ( !Helper :: <E >:: ALLOWS_NON_ASCII ) ;
224- self . read_generic :: < false , false > ( E :: TABLE )
225- }
226- }
227-
228211 fn read_str ( & mut self , s : & str ) -> bool {
229212 if self . bytes [ self . pos ..] . starts_with ( s. as_bytes ( ) ) {
230213 // INVARIANT: The remaining bytes start with `s` so it's fine to skip `s.len()`.
0 commit comments