mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-21 22:02:06 +01:00
Use StringBuilder instead of String concatenation
This commit is contained in:
parent
2391cffa97
commit
85ff749d89
2 changed files with 17 additions and 10 deletions
|
@ -209,15 +209,17 @@ public abstract class OmemoBundleElement implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "OmemoBundleElement[\n";
|
||||
out += SIGNED_PRE_KEY_PUB + " " + SIGNED_PRE_KEY_ID + "=" + signedPreKeyId + ": " + signedPreKeyB64 + "\n";
|
||||
out += SIGNED_PRE_KEY_SIG + ": " + signedPreKeySignatureB64 + "\n";
|
||||
out += IDENTITY_KEY + ": " + identityKeyB64 + "\n";
|
||||
out += PRE_KEYS + " (" + preKeysB64.size() + ")\n";
|
||||
StringBuilder sb = new StringBuilder("OmemoBundleElement[\n");
|
||||
sb.append(SIGNED_PRE_KEY_PUB).append(' ').append(SIGNED_PRE_KEY_ID).append('=').append(signedPreKeyId)
|
||||
.append(':').append(signedPreKeyB64).append('\n')
|
||||
.append(SIGNED_PRE_KEY_SIG).append(": ").append(signedPreKeySignatureB64).append('\n')
|
||||
.append(IDENTITY_KEY).append(": ").append(identityKeyB64).append('\n')
|
||||
.append(PRE_KEYS).append(" (").append(preKeysB64.size()).append(")\n");
|
||||
for (Map.Entry<Integer, String> e : preKeysB64.entrySet()) {
|
||||
out += PRE_KEY_PUB + " " + PRE_KEY_ID + "=" + e.getKey() + ": " + e.getValue() + "\n";
|
||||
sb.append(PRE_KEY_PUB).append(' ').append(PRE_KEY_ID).append("=").append(e.getKey()).append(": ").append(e.getValue()).append("\n");
|
||||
}
|
||||
return out;
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.jivesoftware.smackx.omemo.element;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
@ -78,10 +79,14 @@ public abstract class OmemoDeviceListElement implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public final String toString() {
|
||||
String out = "OmemoDeviceListElement[";
|
||||
StringBuilder sb = new StringBuilder("OmemoDeviceListElement[");
|
||||
Iterator<Integer> iterator = deviceIds.iterator();
|
||||
for (int i : deviceIds) {
|
||||
out += i + ",";
|
||||
sb.append(i);
|
||||
if (iterator.hasNext()) {
|
||||
sb.append(',');
|
||||
}
|
||||
}
|
||||
return out.substring(0, out.length() - 1) + "]";
|
||||
return sb.append(']').toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue