mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-24 11:38:00 +01:00
[core] Optimize Presence.toXML() for empty element
This commit is contained in:
parent
b3c57ef918
commit
962071762a
1 changed files with 12 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.jivesoftware.smack.packet;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.net.SocketFactory;
|
||||
|
@ -309,6 +310,16 @@ public final class Presence extends MessageOrPresence<PresenceBuilder>
|
|||
if (type != Type.available) {
|
||||
buf.attribute("type", type);
|
||||
}
|
||||
|
||||
List<ExtensionElement> extensions = getExtensions();
|
||||
if (status == null
|
||||
&& priority == null
|
||||
&& (mode == null || mode == Mode.available)
|
||||
&& extensions.isEmpty()
|
||||
&& getError() == null) {
|
||||
return buf.closeEmptyElement();
|
||||
}
|
||||
|
||||
buf.rightAngleBracket();
|
||||
|
||||
buf.optElement("status", status);
|
||||
|
@ -317,7 +328,7 @@ public final class Presence extends MessageOrPresence<PresenceBuilder>
|
|||
buf.element("show", mode);
|
||||
}
|
||||
|
||||
buf.append(getExtensions());
|
||||
buf.append(extensions);
|
||||
|
||||
// Add the error sub-packet, if there is one.
|
||||
appendErrorIfExists(buf);
|
||||
|
|
Loading…
Reference in a new issue