@@ -455,62 +455,94 @@ class filter_core:empty_value<Allocator,0>
455
455
template <typename HashStream,typename F>
456
456
BOOST_FORCEINLINE void bulk_may_contain (HashStream h,std::size_t n,F f)const
457
457
{
458
- std:: uint64_t hashes[bulk_may_contain_size];
459
- const unsigned char * positions [bulk_may_contain_size];
460
- bool results [bulk_may_contain_size];
458
+ if (k== 1 ){
459
+ std:: uint64_t hashes [bulk_may_contain_size];
460
+ const unsigned char * positions [bulk_may_contain_size];
461
461
462
- if (n>=2 *bulk_may_contain_size){
463
- for (auto i=bulk_may_contain_size;i--;){
464
- auto & hash=hashes[i]=h ();
465
- auto & p=positions[i];
466
- auto & res=results[i];
467
- hs.prepare_hash (hash);
468
- p=next_element (hash);
469
- res=true ;
470
- }
471
- do {
472
- for (auto j=k-1 ;j--;){
462
+ if (n>=2 *bulk_may_contain_size){
463
+ for (auto i=bulk_may_contain_size;i--;){
464
+ auto & hash=hashes[i]=h ();
465
+ auto & p=positions[i];
466
+ hs.prepare_hash (hash);
467
+ p=next_element (hash);
468
+ }
469
+ do {
473
470
for (auto i=bulk_may_contain_size;i--;){
474
471
auto & hash=hashes[i];
475
472
auto & p=positions[i];
476
- auto & res=results[i];
477
- res&=get (p,hash);
473
+ f (get (p,hash));
474
+ hash=h ();
475
+ hs.prepare_hash (hash);
478
476
p=next_element (hash);
479
477
}
480
- }
478
+ n-=bulk_may_contain_size;
479
+ }while (n>=2 *bulk_may_contain_size);
481
480
for (auto i=bulk_may_contain_size;i--;){
482
481
auto & hash=hashes[i];
483
482
auto & p=positions[i];
483
+ f (get (p,hash));
484
+ }
485
+ n-=bulk_may_contain_size;
486
+ }
487
+ while (n--)f (may_contain (h ()));
488
+ }
489
+ else {
490
+ std::uint64_t hashes[bulk_may_contain_size];
491
+ const unsigned char * positions[bulk_may_contain_size];
492
+ bool results[bulk_may_contain_size];
493
+
494
+ if (n>=2 *bulk_may_contain_size){
495
+ for (auto i=bulk_may_contain_size;i--;){
496
+ auto & hash=hashes[i]=h ();
497
+ auto & p=positions[i];
484
498
auto & res=results[i];
485
- res&=get (p,hash);
486
- f (res);
487
- hash=h ();
488
499
hs.prepare_hash (hash);
489
500
p=next_element (hash);
490
501
res=true ;
491
502
}
492
- n-=bulk_may_contain_size;
493
- }while (n>=2 *bulk_may_contain_size);
494
- for (auto j=k-1 ;j--;){
503
+ do {
504
+ for (auto j=k-1 ;j--;){
505
+ for (auto i=bulk_may_contain_size;i--;){
506
+ auto & hash=hashes[i];
507
+ auto & p=positions[i];
508
+ auto & res=results[i];
509
+ res&=get (p,hash);
510
+ p=next_element (hash);
511
+ }
512
+ }
513
+ for (auto i=bulk_may_contain_size;i--;){
514
+ auto & hash=hashes[i];
515
+ auto & p=positions[i];
516
+ auto & res=results[i];
517
+ res&=get (p,hash);
518
+ f (res);
519
+ hash=h ();
520
+ hs.prepare_hash (hash);
521
+ p=next_element (hash);
522
+ res=true ;
523
+ }
524
+ n-=bulk_may_contain_size;
525
+ }while (n>=2 *bulk_may_contain_size);
526
+ for (auto j=k-1 ;j--;){
527
+ for (auto i=bulk_may_contain_size;i--;){
528
+ auto & hash=hashes[i];
529
+ auto & p=positions[i];
530
+ auto & res=results[i];
531
+ res&=get (p,hash);
532
+ p=next_element (hash);
533
+ }
534
+ }
495
535
for (auto i=bulk_may_contain_size;i--;){
496
536
auto & hash=hashes[i];
497
537
auto & p=positions[i];
498
538
auto & res=results[i];
499
539
res&=get (p,hash);
500
- p= next_element (hash );
540
+ f (res );
501
541
}
542
+ n-=bulk_may_contain_size;
502
543
}
503
- for (auto i=bulk_may_contain_size;i--;){
504
- auto & hash=hashes[i];
505
- auto & p=positions[i];
506
- auto & res=results[i];
507
- res&=get (p,hash);
508
- f (res);
509
- }
510
- n-=bulk_may_contain_size;
544
+ while (n--)f (may_contain (h ()));
511
545
}
512
- while (n--)f (may_contain (h ()));
513
-
514
546
#if 0
515
547
while(n>=2*bulk_may_contain_size){
516
548
bulk_may_contain_impl(h,bulk_may_contain_size,f);
0 commit comments