From e090067358da1b0f2d15362336ed0c174725887f Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 21 Oct 2014 23:37:37 +0200 Subject: [PATCH] Use switch/case instead if/else-if in parsePackets() --- .../jivesoftware/smack/tcp/XMPPTCPConnection.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index 42eecd238..09fff0b3c 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -1010,8 +1010,9 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { try { initalOpenStreamSend.checkIfSuccessOrWait(); int eventType = parser.getEventType(); - do { - if (eventType == XmlPullParser.START_TAG) { + while (!done && eventType != XmlPullParser.END_DOCUMENT) { + switch (eventType) { + case XmlPullParser.START_TAG: final String name = parser.getName(); switch (name) { case Message.ELEMENT: @@ -1199,15 +1200,16 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { LOGGER.warning("Unkown top level stream element: " + name); break; } - } - else if (eventType == XmlPullParser.END_TAG) { + break; + case XmlPullParser.END_TAG: if (parser.getName().equals("stream")) { // Disconnect the connection disconnect(); } + break; } eventType = parser.next(); - } while (!done && eventType != XmlPullParser.END_DOCUMENT); + } } catch (Exception e) { // The exception can be ignored if the the connection is 'done'