mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 14:22:05 +01:00
Make MarkableExtension a singleton
to reduce pressure on the memory subsystem.
This commit is contained in:
parent
45736e8ead
commit
b12f5a1591
4 changed files with 7 additions and 5 deletions
|
@ -125,7 +125,7 @@ public final class ChatMarkersManager extends Manager {
|
|||
SmackException.NotLoggedInException {
|
||||
Message message = (Message) packet;
|
||||
// add a markable extension
|
||||
message.addExtension(new ChatMarkersElements.MarkableExtension());
|
||||
message.addExtension(ChatMarkersElements.MarkableExtension.INSTANCE);
|
||||
}
|
||||
}, OUTGOING_MESSAGE_FILTER);
|
||||
|
||||
|
|
|
@ -41,14 +41,16 @@ public class ChatMarkersElements {
|
|||
* @author Fernando Ramirez
|
||||
*
|
||||
*/
|
||||
public static class MarkableExtension implements ExtensionElement {
|
||||
public static final class MarkableExtension implements ExtensionElement {
|
||||
|
||||
public static final MarkableExtension INSTANCE = new MarkableExtension();
|
||||
|
||||
/**
|
||||
* markable element.
|
||||
*/
|
||||
public static final String ELEMENT = ChatMarkersState.markable.toString();
|
||||
|
||||
public MarkableExtension() {
|
||||
private MarkableExtension() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,7 +34,7 @@ public class MarkableProvider extends ExtensionElementProvider<MarkableExtension
|
|||
|
||||
@Override
|
||||
public MarkableExtension parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||
return new MarkableExtension();
|
||||
return MarkableExtension.INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class MarkableExtensionTest {
|
|||
Message message = new Message(JidCreate.from("ingrichard@royalty.england.lit/throne"));
|
||||
message.setStanzaId("message-1");
|
||||
message.setBody("My lord, dispatch; read o'er these articles.");
|
||||
message.addExtension(new ChatMarkersElements.MarkableExtension());
|
||||
message.addExtension(ChatMarkersElements.MarkableExtension.INSTANCE);
|
||||
Assert.assertEquals(markableMessageStanza, message.toXML(null).toString());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue