mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 03:52:06 +01:00
Improve XMPPTCPConnection.processHandledCount(long)
Add shortcut: If stanzaAcknowledgedListeners is not empty, then we don't need to check the stanzaIdAcknowledgedListeners. Also fixes a bug, instead of if (id != null && stanzaAcknowledgedListeners.contains(id)) { it must be if (id != null && stanzaIdAcknowledgedListeners.containsKey(id)) {
This commit is contained in:
parent
07539820c3
commit
24b940138f
1 changed files with 14 additions and 7 deletions
|
@ -1630,17 +1630,24 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
ackedStanzas.add(ackedStanza);
|
||||
}
|
||||
|
||||
boolean atLeastOneStanzaIdAcknowledgedListener = false;
|
||||
boolean atLeastOneStanzaAcknowledgedListener = false;
|
||||
if (!stanzaAcknowledgedListeners.isEmpty()) {
|
||||
// If stanzaAcknowledgedListeners is not empty, the we have at least one
|
||||
atLeastOneStanzaAcknowledgedListener = true;
|
||||
}
|
||||
else {
|
||||
// Otherwise we look for a matching id in the stanza *id* acknowledged listeners
|
||||
for (Packet ackedStanza : ackedStanzas) {
|
||||
String id = ackedStanza.getPacketID();
|
||||
if (id != null && stanzaAcknowledgedListeners.contains(id)) {
|
||||
atLeastOneStanzaIdAcknowledgedListener = true;
|
||||
if (id != null && stanzaIdAcknowledgedListeners.containsKey(id)) {
|
||||
atLeastOneStanzaAcknowledgedListener = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only spawn a new thread if there is a chance that some listener is invoked
|
||||
if (atLeastOneStanzaIdAcknowledgedListener || !stanzaAcknowledgedListeners.isEmpty()) {
|
||||
if (atLeastOneStanzaAcknowledgedListener) {
|
||||
asyncGo(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
Loading…
Reference in a new issue