@@ -79,23 +79,23 @@ bool GrammarApplicator::updateRuleToCohorts(Cohort& c, const uint32_t& rsit) {
7979 }
8080 if (!csi.empty ()) {
8181 auto cap = cohortset.capacity ();
82- std::vector<CohortSet::const_iterator *> ends;
83- std::vector<std::pair<CohortSet::const_iterator *,Cohort*>> chs;
82+ std::vector<size_t *> ends;
83+ std::vector<std::pair<size_t *,Cohort*>> chs;
8484 for (size_t i = 0 ; i < csi.size (); ++i) {
85- if (*rocits[csi[i]] == cohortset.end ()) {
85+ if (*rocits[csi[i]] >= cohortset.size ()) {
8686 ends.push_back (rocits[csi[i]]);
8787 }
8888 else {
89- chs.push_back (std::pair (rocits[csi[i]], ** rocits[csi[i]]));
89+ chs.push_back (std::pair (rocits[csi[i]], cohortset. at (* rocits[csi[i]]) ));
9090 }
9191 }
9292 cohortset.insert (&c);
9393 for (auto it : ends) {
94- *it = cohortset.end ();
94+ *it = cohortset.size ();
9595 }
9696 if (cap != cohortset.capacity ()) {
9797 for (auto & it : chs) {
98- *it.first = cohortset.find (it.second );
98+ *it.first = cohortset.find_n (it.second );
9999 }
100100 }
101101 }
@@ -375,9 +375,9 @@ bool GrammarApplicator::runSingleRule(SingleWindow& current, const Rule& rule, R
375375 if (debug_level > 1 ) {
376376 std::cerr << " DEBUG: " << cohortset->size () << " /" << current.cohorts .size () << " = " << double (cohortset->size ()) / double (current.cohorts .size ()) << std::endl;
377377 }
378- for (auto rocit = cohortset-> cbegin (); (!cohortset-> empty ()) && ( rocit != cohortset->cend () );) {
378+ for (size_t rocit = 0 ; rocit < cohortset->size ( );) {
379379 rocits.back () = &rocit;
380- Cohort* cohort = * rocit;
380+ Cohort* cohort = cohortset-> at ( rocit) ;
381381 ++rocit;
382382
383383 finish_reading_loop = true ;
@@ -529,14 +529,10 @@ bool GrammarApplicator::runSingleRule(SingleWindow& current, const Rule& rule, R
529529 cohortset = ¤t.rule_to_cohorts [rule.number ];
530530 override_cohortset ();
531531 cohortsets.back () = cohortset;
532- if (get_apply_to ().cohort ->type & (CT_REMOVED | CT_IGNORED)) {
533- rocit = cohortset->lower_bound (current.cohorts [get_apply_to ().cohort ->local_number ]);
534- }
535- else {
536- rocit = cohortset->find (current.cohorts [get_apply_to ().cohort ->local_number ]);
537- if (rocit != cohortset->end ()) {
538- ++rocit;
539- }
532+ auto gac = get_apply_to ().cohort ;
533+ rocit = gac->local_number ;
534+ if (!(gac->type & (CT_REMOVED | CT_IGNORED)) && rocit < cohortset->size ()) {
535+ ++rocit;
540536 }
541537 };
542538
@@ -790,7 +786,7 @@ bool GrammarApplicator::runSingleRule(SingleWindow& current, const Rule& rule, R
790786 if (num_active == 0 && (num_iff == 0 || rule.type != K_IFF)) {
791787 if (!matched_target) {
792788 --rocit; // We have already incremented rocit earlier, so take one step back...
793- rocit = cohortset->erase (rocit); // ...and one step forward again
789+ cohortset->erase_n (rocit); // ...and one step forward again
794790 }
795791 context_stack.pop_back ();
796792 continue ;
@@ -1223,7 +1219,7 @@ uint32_t GrammarApplicator::runRulesOnSingleWindow(SingleWindow& current, const
12231219 }
12241220 else if (current.next ) {
12251221 current.next ->text = current.text_post + current.next ->text ;
1226- current.next ->all_cohorts .insert (current.previous ->all_cohorts .begin () + 1 , current.all_cohorts .begin () + 1 , current.all_cohorts .end ());
1222+ current.next ->all_cohorts .insert (current.next ->all_cohorts .begin () + 1 , current.all_cohorts .begin () + 1 , current.all_cohorts .end ());
12271223 }
12281224 current.all_cohorts .clear ();
12291225
@@ -1755,9 +1751,9 @@ uint32_t GrammarApplicator::runRulesOnSingleWindow(SingleWindow& current, const
17551751 cCohort->relations .swap (get_apply_to ().cohort ->relations );
17561752
17571753 std::pair<SingleWindow**, size_t > swss[3 ] = {
1758- std::make_pair (& gWindow ->previous [ 0 ] , gWindow ->previous .size ()),
1754+ std::make_pair (gWindow ->previous . data () , gWindow ->previous .size ()),
17591755 std::make_pair (&gWindow ->current , static_cast <size_t >(1 )),
1760- std::make_pair (& gWindow ->next [ 0 ] , gWindow ->next .size ()),
1756+ std::make_pair (gWindow ->next . data () , gWindow ->next .size ()),
17611757 };
17621758 for (auto sws : swss) {
17631759 for (size_t sw = 0 ; sw < sws.second ; ++sw) {
0 commit comments