SSU: Change remaining acks from List to Set (ticket #2258)

This commit is contained in:
zzz
2018-07-06 13:27:38 +00:00
parent 7aca1e4006
commit 1460bec8cf
2 changed files with 5 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@@ -386,7 +387,7 @@ class OutboundMessageFragments {
int piggybackedPartialACK = partialACKBitfields.size(); int piggybackedPartialACK = partialACKBitfields.size();
// getCurrentFullACKs() already makes a copy, do we need to copy again? // getCurrentFullACKs() already makes a copy, do we need to copy again?
// YES because buildPacket() now removes them (maybe) // YES because buildPacket() now removes them (maybe)
List<Long> remaining = new ArrayList<Long>(msgIds); Set<Long> remaining = new HashSet<Long>(msgIds);
// build the list of fragments to send // build the list of fragments to send
List<Fragment> toSend = new ArrayList<Fragment>(8); List<Fragment> toSend = new ArrayList<Fragment>(8);

View File

@@ -5,6 +5,7 @@ import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@@ -290,7 +291,7 @@ class PacketBuilder {
* @return null on error * @return null on error
*/ */
public UDPPacket buildPacket(OutboundMessageState state, int fragment, PeerState peer, public UDPPacket buildPacket(OutboundMessageState state, int fragment, PeerState peer,
List<Long> ackIdsRemaining, int newAckCount, Collection<Long> ackIdsRemaining, int newAckCount,
List<ACKBitfield> partialACKsRemaining) { List<ACKBitfield> partialACKsRemaining) {
List<Fragment> frags = Collections.singletonList(new Fragment(state, fragment)); List<Fragment> frags = Collections.singletonList(new Fragment(state, fragment));
return buildPacket(frags, peer, ackIdsRemaining, newAckCount, partialACKsRemaining); return buildPacket(frags, peer, ackIdsRemaining, newAckCount, partialACKsRemaining);
@@ -302,7 +303,7 @@ class PacketBuilder {
* @since 0.9.16 * @since 0.9.16
*/ */
public UDPPacket buildPacket(List<Fragment> fragments, PeerState peer, public UDPPacket buildPacket(List<Fragment> fragments, PeerState peer,
List<Long> ackIdsRemaining, int newAckCount, Collection<Long> ackIdsRemaining, int newAckCount,
List<ACKBitfield> partialACKsRemaining) { List<ACKBitfield> partialACKsRemaining) {
StringBuilder msg = null; StringBuilder msg = null;
if (_log.shouldLog(Log.INFO)) { if (_log.shouldLog(Log.INFO)) {