@@ -333,44 +333,30 @@ pub struct BlockSplitIterator<'a, Alloc: alloc::Allocator<u8> + 'a + alloc::Allo
333333 pub length_ : usize ,
334334}
335335
336- fn NewBlockSplitIterator < ' a , Alloc : alloc:: Allocator < u8 > + alloc:: Allocator < u32 > > (
337- split : & ' a BlockSplit < Alloc > ,
338- ) -> BlockSplitIterator < ' a , Alloc > {
339- return BlockSplitIterator :: < ' a > {
340- split_ : split,
341- idx_ : 0usize ,
342- type_ : 0usize ,
343- length_ : if !split. lengths . slice ( ) . is_empty ( ) {
344- split. lengths . slice ( ) [ 0 ] as usize
345- } else {
346- 0usize
347- } ,
348- } ;
349- }
350-
351- fn InitBlockSplitIterator < ' a , Alloc : alloc:: Allocator < u8 > + alloc:: Allocator < u32 > > (
352- xself : & ' a mut BlockSplitIterator < ' a , Alloc > ,
353- split : & ' a BlockSplit < Alloc > ,
354- ) {
355- xself. split_ = split;
356- xself. idx_ = 0usize ;
357- xself. type_ = 0usize ;
358- xself. length_ = if !split. lengths . slice ( ) . is_empty ( ) {
359- split. lengths . slice ( ) [ 0 ]
360- } else {
361- 0u32
362- } as usize ;
363- }
364- fn BlockSplitIteratorNext < ' a , Alloc : alloc:: Allocator < u8 > + alloc:: Allocator < u32 > > (
365- xself : & mut BlockSplitIterator < Alloc > ,
366- ) {
367- if xself. length_ == 0usize {
368- xself. idx_ = xself. idx_ . wrapping_add ( 1 ) ;
369- xself. type_ = xself. split_ . types . slice ( ) [ xself. idx_ ] as usize ;
370- xself. length_ = xself. split_ . lengths . slice ( ) [ xself. idx_ ] as usize ;
336+ impl < ' a , Alloc : alloc:: Allocator < u8 > + alloc:: Allocator < u32 > + ' a > BlockSplitIterator < ' a , Alloc > {
337+ fn new ( split : & ' a BlockSplit < Alloc > ) -> Self {
338+ Self {
339+ split_ : split,
340+ idx_ : 0 ,
341+ type_ : 0 ,
342+ length_ : if !split. lengths . slice ( ) . is_empty ( ) {
343+ split. lengths . slice ( ) [ 0 ] as usize
344+ } else {
345+ 0
346+ } ,
347+ }
348+ }
349+
350+ fn next ( & mut self ) {
351+ if self . length_ == 0 {
352+ self . idx_ = self . idx_ . wrapping_add ( 1 ) ;
353+ self . type_ = self . split_ . types . slice ( ) [ self . idx_ ] as usize ;
354+ self . length_ = self . split_ . lengths . slice ( ) [ self . idx_ ] as usize ;
355+ }
356+ self . length_ = self . length_ . wrapping_sub ( 1 ) ;
371357 }
372- xself. length_ = xself. length_ . wrapping_sub ( 1 ) ;
373358}
359+
374360pub fn HistogramAddItem < HistogramType : SliceWrapper < u32 > + SliceWrapperMut < u32 > + CostAccessors > (
375361 xself : & mut HistogramType ,
376362 val : usize ,
@@ -499,21 +485,21 @@ pub fn BrotliBuildHistogramsWithContext<'a, Alloc: alloc::Allocator<u8> + alloc:
499485 let mut literal_it: BlockSplitIterator < Alloc > ;
500486 let mut insert_and_copy_it: BlockSplitIterator < Alloc > ;
501487 let mut dist_it: BlockSplitIterator < Alloc > ;
502- literal_it = NewBlockSplitIterator ( literal_split) ;
503- insert_and_copy_it = NewBlockSplitIterator ( insert_and_copy_split) ;
504- dist_it = NewBlockSplitIterator ( dist_split) ;
488+ literal_it = BlockSplitIterator :: new ( literal_split) ;
489+ insert_and_copy_it = BlockSplitIterator :: new ( insert_and_copy_split) ;
490+ dist_it = BlockSplitIterator :: new ( dist_split) ;
505491 for i in 0usize ..num_commands {
506492 let cmd = & cmds[ i] ;
507493 let mut j: usize ;
508- BlockSplitIteratorNext ( & mut insert_and_copy_it) ;
494+ insert_and_copy_it. next ( ) ;
509495 HistogramAddItem (
510496 & mut insert_and_copy_histograms[ insert_and_copy_it. type_ ] ,
511497 cmd. cmd_prefix_ as usize ,
512498 ) ;
513499 j = cmd. insert_len_ as usize ;
514500 while j != 0usize {
515501 {
516- BlockSplitIteratorNext ( & mut literal_it) ;
502+ literal_it. next ( ) ;
517503 let context: usize = if !context_modes. is_empty ( ) {
518504 ( literal_it. type_ << 6 ) . wrapping_add ( Context (
519505 prev_byte,
@@ -538,7 +524,7 @@ pub fn BrotliBuildHistogramsWithContext<'a, Alloc: alloc::Allocator<u8> + alloc:
538524 prev_byte2 = ringbuffer[ ( pos. wrapping_sub ( 2 ) & mask) ] ;
539525 prev_byte = ringbuffer[ ( pos. wrapping_sub ( 1 ) & mask) ] ;
540526 if cmd. cmd_prefix_ as i32 >= 128i32 {
541- BlockSplitIteratorNext ( & mut dist_it) ;
527+ dist_it. next ( ) ;
542528 let context: usize =
543529 ( dist_it. type_ << 2 ) . wrapping_add ( cmd. distance_context ( ) as usize ) ;
544530 HistogramAddItem (
0 commit comments