Skip to content

Fix a bug

Alexander Trufanov requested to merge trufanov/libktorrent:bug into master

It seems I've introduced a bug with my commit "Improve BitSet operations performance". I've optimized performance for BitSet::includesBitSet() which looked like:

		Uint32 i = 0;
		while (i < num_bits)
		{
			if (other.get(i) && !get(i))
				return false;
			i++;
		}
		return true;

And after that I found out that BitSet::includesBitSet is never really used in the project.

But there is a piece of code in advancedchokealgorythm.cpp that looked like:

		for (Uint32 i = 0;i < ours.getNumBits();i++)
		{
			if (ours.get(i) && !theirs.get(i))
			{
				should_be_interested = true;
				break;
			}
		}

And I replaced it with

should_be_interested = !ours.includesBitSet(theirs);

That was a mistake. It must be:

should_be_interested = !theirs.includesBitSet(ours);

As a result there appeared a problem with starting a torrent seeding.

Merge request reports