From b12f5a15912524c9ed26b77b8209b083e11f8fb4 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 6 Sep 2018 18:45:41 +0200 Subject: [PATCH] Make MarkableExtension a singleton to reduce pressure on the memory subsystem. --- .../smackx/chat_markers/ChatMarkersManager.java | 2 +- .../smackx/chat_markers/element/ChatMarkersElements.java | 6 ++++-- .../smackx/chat_markers/provider/MarkableProvider.java | 2 +- .../smackx/chat_markers/MarkableExtensionTest.java | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/ChatMarkersManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/ChatMarkersManager.java index 6f75e71ab..32a2edaf0 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/ChatMarkersManager.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/ChatMarkersManager.java @@ -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); diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/element/ChatMarkersElements.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/element/ChatMarkersElements.java index 53b2b8552..46e81435a 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/element/ChatMarkersElements.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/element/ChatMarkersElements.java @@ -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 diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/provider/MarkableProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/provider/MarkableProvider.java index f4c4384bb..c243b57da 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/provider/MarkableProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/provider/MarkableProvider.java @@ -34,7 +34,7 @@ public class MarkableProvider extends ExtensionElementProvider