@@ -333,44 +333,30 @@ pub struct BlockSplitIterator<'a, Alloc: alloc::Allocator<u8> + 'a + alloc::Allo
333
333
pub length_ : usize ,
334
334
}
335
335
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 ) ;
371
357
}
372
- xself. length_ = xself. length_ . wrapping_sub ( 1 ) ;
373
358
}
359
+
374
360
pub fn HistogramAddItem < HistogramType : SliceWrapper < u32 > + SliceWrapperMut < u32 > + CostAccessors > (
375
361
xself : & mut HistogramType ,
376
362
val : usize ,
@@ -499,21 +485,21 @@ pub fn BrotliBuildHistogramsWithContext<'a, Alloc: alloc::Allocator<u8> + alloc:
499
485
let mut literal_it: BlockSplitIterator < Alloc > ;
500
486
let mut insert_and_copy_it: BlockSplitIterator < Alloc > ;
501
487
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) ;
505
491
for i in 0usize ..num_commands {
506
492
let cmd = & cmds[ i] ;
507
493
let mut j: usize ;
508
- BlockSplitIteratorNext ( & mut insert_and_copy_it) ;
494
+ insert_and_copy_it. next ( ) ;
509
495
HistogramAddItem (
510
496
& mut insert_and_copy_histograms[ insert_and_copy_it. type_ ] ,
511
497
cmd. cmd_prefix_ as usize ,
512
498
) ;
513
499
j = cmd. insert_len_ as usize ;
514
500
while j != 0usize {
515
501
{
516
- BlockSplitIteratorNext ( & mut literal_it) ;
502
+ literal_it. next ( ) ;
517
503
let context: usize = if !context_modes. is_empty ( ) {
518
504
( literal_it. type_ << 6 ) . wrapping_add ( Context (
519
505
prev_byte,
@@ -538,7 +524,7 @@ pub fn BrotliBuildHistogramsWithContext<'a, Alloc: alloc::Allocator<u8> + alloc:
538
524
prev_byte2 = ringbuffer[ ( pos. wrapping_sub ( 2 ) & mask) ] ;
539
525
prev_byte = ringbuffer[ ( pos. wrapping_sub ( 1 ) & mask) ] ;
540
526
if cmd. cmd_prefix_ as i32 >= 128i32 {
541
- BlockSplitIteratorNext ( & mut dist_it) ;
527
+ dist_it. next ( ) ;
542
528
let context: usize =
543
529
( dist_it. type_ << 2 ) . wrapping_add ( cmd. distance_context ( ) as usize ) ;
544
530
HistogramAddItem (
0 commit comments