From 14b33a1e4c45376af592405f2ba84413ff415381 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Mon, 6 Apr 2020 15:23:30 +0000 Subject: [PATCH] Ratchet: Don't allocate space for tagset keys initially --- .../java/src/net/i2p/router/crypto/ratchet/RatchetTagSet.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/router/java/src/net/i2p/router/crypto/ratchet/RatchetTagSet.java b/router/java/src/net/i2p/router/crypto/ratchet/RatchetTagSet.java index 470993f927..1c7049e345 100644 --- a/router/java/src/net/i2p/router/crypto/ratchet/RatchetTagSet.java +++ b/router/java/src/net/i2p/router/crypto/ratchet/RatchetTagSet.java @@ -86,6 +86,8 @@ class RatchetTagSet implements TagSetHandle { static final int DEBUG_OB_NSR = 0x10001; static final int DEBUG_IB_NSR = 0x10002; static final int DEBUG_SINGLE_ES = 0x10003; + // Start empty (no allocations), we only use storage for gaps + private static final int INITIAL_KEY_CAPACITY = 0; /** * Outbound NSR Tagset @@ -160,7 +162,7 @@ class RatchetTagSet implements TagSetHandle { if (isInbound) { _sessionTags = new SparseArray<RatchetSessionTag>(minSize); if (state == null) - _sessionKeys = new SparseArray<byte[]>(minSize); + _sessionKeys = new SparseArray<byte[]>(INITIAL_KEY_CAPACITY); else _sessionKeys = null; for (int i = 0; i < minSize; i++) { -- GitLab