From b84e83537dd584736cdc5d85702fbcb169ada106 Mon Sep 17 00:00:00 2001 From: leventov Date: Sun, 25 Jan 2015 08:56:53 +0700 Subject: [PATCH] When VanillaContext keys/values are CharSequences, use StringBuilder as reusable instances --- .../net/openhft/chronicle/map/VanillaContext.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/VanillaContext.java b/src/main/java/net/openhft/chronicle/map/VanillaContext.java index 3e45bba02..02b87c848 100644 --- a/src/main/java/net/openhft/chronicle/map/VanillaContext.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaContext.java @@ -251,16 +251,11 @@ class VanillaContext, K reusableKey; V reusableValue; MapAndContextLocals(ChronicleMap map) { -// try { -// reusableKey = map.newKeyInstance(); -// } catch (Exception e) { -// // ignore -// } -// try { -// reusableValue = map.newValueInstance(); -// } catch (Exception e) { -// // ignore -// } + // TODO why not using map.newKeyInstance() and newValueInstance() + if (map.keyClass() == CharSequence.class) + reusableKey = (K) new StringBuilder(); + if (map.valueClass() == CharSequence.class) + reusableValue = (V) new StringBuilder(); } }