@@ -2127,8 +2127,7 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] {
2127
2127
#[ inline]
2128
2128
fn mut_chunks ( self , chunk_size : uint ) -> MutChunkIter < ' a , T > {
2129
2129
assert ! ( chunk_size > 0 ) ;
2130
- let len = self . len ( ) ;
2131
- MutChunkIter { v : self , chunk_size : chunk_size, remaining : len }
2130
+ MutChunkIter { v : self , chunk_size : chunk_size }
2132
2131
}
2133
2132
2134
2133
fn mut_shift_ref ( & mut self ) -> & ' a mut T {
@@ -2568,31 +2567,29 @@ impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutSplitIterator<'a, T> {
2568
2567
/// the remainder.
2569
2568
pub struct MutChunkIter < ' a , T > {
2570
2569
priv v: & ' a mut [ T ] ,
2571
- priv chunk_size : uint ,
2572
- priv remaining : uint
2570
+ priv chunk_size : uint
2573
2571
}
2574
2572
2575
2573
impl < ' a , T > Iterator < & ' a mut [ T ] > for MutChunkIter < ' a , T > {
2576
2574
#[ inline]
2577
2575
fn next ( & mut self ) -> Option < & ' a mut [ T ] > {
2578
- if self . remaining == 0 {
2576
+ if self . v . len ( ) == 0 {
2579
2577
None
2580
2578
} else {
2581
- let sz = cmp:: min ( self . remaining , self . chunk_size ) ;
2579
+ let sz = cmp:: min ( self . v . len ( ) , self . chunk_size ) ;
2582
2580
let tmp = util:: replace ( & mut self . v , & mut [ ] ) ;
2583
2581
let ( head, tail) = tmp. mut_split_at ( sz) ;
2584
2582
self . v = tail;
2585
- self . remaining -= sz;
2586
2583
Some ( head)
2587
2584
}
2588
2585
}
2589
2586
2590
2587
#[ inline]
2591
2588
fn size_hint ( & self ) -> ( uint , Option < uint > ) {
2592
- if self . remaining == 0 {
2589
+ if self . v . len ( ) == 0 {
2593
2590
( 0 , Some ( 0 ) )
2594
2591
} else {
2595
- let ( n, rem) = self . remaining . div_rem ( & self . chunk_size ) ;
2592
+ let ( n, rem) = self . v . len ( ) . div_rem ( & self . chunk_size ) ;
2596
2593
let n = if rem > 0 { n + 1 } else { n } ;
2597
2594
( n, Some ( n) )
2598
2595
}
@@ -2602,15 +2599,15 @@ impl<'a, T> Iterator<&'a mut [T]> for MutChunkIter<'a, T> {
2602
2599
impl < ' a , T > DoubleEndedIterator < & ' a mut [ T ] > for MutChunkIter < ' a , T > {
2603
2600
#[ inline]
2604
2601
fn next_back ( & mut self ) -> Option < & ' a mut [ T ] > {
2605
- if self . remaining == 0 {
2602
+ if self . v . len ( ) == 0 {
2606
2603
None
2607
2604
} else {
2608
- let remainder = self . remaining % self . chunk_size ;
2605
+ let remainder = self . v . len ( ) % self . chunk_size ;
2609
2606
let sz = if remainder != 0 { remainder } else { self . chunk_size } ;
2610
2607
let tmp = util:: replace ( & mut self . v , & mut [ ] ) ;
2611
- let ( head, tail) = tmp. mut_split_at ( self . remaining - sz) ;
2608
+ let tmp_len = tmp. len ( ) ;
2609
+ let ( head, tail) = tmp. mut_split_at ( tmp_len - sz) ;
2612
2610
self . v = head;
2613
- self . remaining -= sz;
2614
2611
Some ( tail)
2615
2612
}
2616
2613
}
0 commit comments