File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -568,6 +568,7 @@ pub struct BitvIterator<'self> {
568
568
}
569
569
570
570
impl < ' self > Iterator < bool > for BitvIterator < ' self > {
571
+ #[ inline]
571
572
fn next ( & mut self ) -> Option < bool > {
572
573
if self . next_idx < self . bitv . nbits {
573
574
let idx = self . next_idx ;
@@ -866,6 +867,7 @@ pub struct BitvSetIterator<'self> {
866
867
}
867
868
868
869
impl < ' self > Iterator < uint > for BitvSetIterator < ' self > {
870
+ #[ inline]
869
871
fn next( & mut self ) -> Option < uint > {
870
872
while self . next_idx < self . set. capacity ( ) {
871
873
let idx = self . next_idx ;
@@ -1566,4 +1568,38 @@ mod tests {
1566
1568
b1. union ( & b2) ;
1567
1569
}
1568
1570
}
1571
+
1572
+ #[ bench]
1573
+ fn bench_btv_small_iter ( b : & mut BenchHarness ) {
1574
+ let bitv = Bitv :: new ( uint:: bits, false ) ;
1575
+ do b. iter {
1576
+ let mut sum = 0 ;
1577
+ for bitv . iter( ) . advance |pres| {
1578
+ sum += pres as uint;
1579
+ }
1580
+ }
1581
+ }
1582
+
1583
+ #[ bench]
1584
+ fn bench_bitv_big_iter ( b : & mut BenchHarness ) {
1585
+ let bitv = Bitv :: new ( BENCH_BITS , false ) ;
1586
+ do b. iter {
1587
+ let mut sum = 0 ;
1588
+ for bitv . iter( ) . advance |pres| {
1589
+ sum += pres as uint;
1590
+ }
1591
+ }
1592
+ }
1593
+
1594
+ #[ bench]
1595
+ fn bench_bitvset_iter ( b : & mut BenchHarness ) {
1596
+ let bitv = BitvSet :: from_bitv ( from_fn ( BENCH_BITS ,
1597
+ |idx| { idx % 3 == 0 } ) ) ;
1598
+ do b. iter {
1599
+ let mut sum = 0 ;
1600
+ for bitv . iter( ) . advance |idx| {
1601
+ sum += idx;
1602
+ }
1603
+ }
1604
+ }
1569
1605
}
You can’t perform that action at this time.
0 commit comments