@@ -330,15 +330,18 @@ template <class uword> size_t EWAHBoolArray<uword>::numberOfWords() const {
330330}
331331
332332template <class uword >
333- void EWAHBoolArray<uword>::checkWordCount (std::string message) const {
333+ void EWAHBoolArray<uword>::assertWordCount (std::string message) const {
334334#ifdef EWAHASSERT
335335 size_t tot = numberOfWords ();
336336 size_t expected = (sizeinbits + wordinbits - 1 ) / wordinbits;
337337 if (expected != tot) {
338- std::cerr << " [checkWordCount] " << message << std::endl;
339- std::cerr << " [checkWordCount] number of words " << tot << std::endl;
340- std::cerr << " [checkWordCount] expected number of words " << expected
338+ std::cerr << " [assertWordCount] wordinbits " << wordinbits << std::endl;
339+ std::cerr << " [assertWordCount] sizeinbits " << sizeinbits << std::endl;
340+ std::cerr << " [assertWordCount] " << message << std::endl;
341+ std::cerr << " [assertWordCount] number of words " << tot << std::endl;
342+ std::cerr << " [assertWordCount] expected number of words " << expected
341343 << std::endl;
344+ debugprintout ();
342345 throw std::runtime_error (" bug" );
343346 }
344347#endif
@@ -1413,11 +1416,14 @@ void EWAHBoolArray<uword>::logicaland(const EWAHBoolArray &a,
14131416 rlwj.discardLiteralWordsWithReload (nbre_literal);
14141417 }
14151418 }
1416- container.setSizeInBits (sizeInBits ());
1419+ BufferedRunningLengthWord<uword> &remain = rlwj.size () > 0 ? rlwj : rlwi;
1420+ while (remain.size () > 0 ) {
1421+ container.addStreamOfEmptyWords (false , remain.size ());
1422+ if (!remain.next ()) { break ; }
1423+ }
14171424 container.setSizeInBits (sizeInBits () > a.sizeInBits () ? sizeInBits ()
14181425 : a.sizeInBits ());
1419- container.correctWordCount ();
1420- container.checkWordCount (" logicaland" );
1426+ container.assertWordCount (" logicaland" );
14211427}
14221428
14231429template <class uword >
@@ -1473,13 +1479,17 @@ void EWAHBoolArray<uword>::logicalandnot(const EWAHBoolArray &a,
14731479 rlwj.discardLiteralWordsWithReload (nbre_literal);
14741480 }
14751481 }
1476- const bool i_remains = rlwi.size () > 0 ;
1477- if (i_remains) {
1482+ if (rlwi.size () > 0 ) {
14781483 rlwi.discharge (container);
1484+ container.setSizeInBits (sizeInBits ());
1485+ } else {
1486+ while (rlwj.size () > 0 ) {
1487+ container.addStreamOfEmptyWords (false , rlwj.size ());
1488+ if (!rlwj.next ()) { break ; }
1489+ }
1490+ container.setSizeInBits (a.sizeInBits ());
14791491 }
1480- container.setSizeInBits (sizeInBits ());
1481- container.correctWordCount ();
1482- container.checkWordCount (" logicalandnot" );
1492+ container.assertWordCount (" logicalandnot" );
14831493}
14841494
14851495template <class uword >
0 commit comments