@@ -0,0 +1,1822 @@
+package net.openhft.chronicle.core.pool;%0A%0Aimport net.openhft.chronicle.core.Maths;%0Aimport net.openhft.chronicle.core.util.StringUtils;%0Aimport org.jetbrains.annotations.Nullable;%0A%0Aimport java.util.function.Function;%0Aimport java.util.stream.Stream;%0A%0A/**%0A * Created by peter on 29/02/16.%0A */%0Apublic class ParsingCache%3CE%3E %7B%0A    protected final ParsedData%3CE%3E%5B%5D interner;%0A    protected final int mask, shift;%0A    private final Function%3CString, E%3E eFunction;%0A    protected boolean toggle = false;%0A%0A    public ParsingCache(int capacity, Function%3CString, E%3E eFunction) throws IllegalArgumentException %7B%0A        this.eFunction = eFunction;%0A        int n = Maths.nextPower2(capacity, 128);%0A        shift = Maths.intLog2(n);%0A        interner = new ParsedData%5Bn%5D;%0A        mask = n - 1;%0A    %7D%0A%0A    @Nullable%0A    public E intern(@Nullable CharSequence cs) %7B%0A        if (cs == null)%0A            return null;%0A        int hash = Maths.hash32(cs);%0A        int h = hash & mask;%0A        ParsedData%3CE%3E s = interner%5Bh%5D;%0A        if (StringUtils.isEqual(s.string, cs))%0A            return s.e;%0A        int h2 = (hash %3E%3E shift) & mask;%0A        ParsedData%3CE%3E s2 = interner%5Bh2%5D;%0A        if (StringUtils.isEqual(s2.string, cs))%0A            return s2.e;%0A        String string = cs.toString();%0A        ParsedData%3CE%3E s3 = new ParsedData%3C%3E(string, eFunction.apply(string));%0A        interner%5Bs == null %7C%7C (s2 != null && toggle()) ? h : h2%5D = s3;%0A%0A        return s3.e;%0A    %7D%0A%0A    protected boolean toggle() %7B%0A        return toggle = !toggle;%0A    %7D%0A%0A    public int valueCount() %7B%0A        return (int) Stream.of(interner).filter(s -%3E s != null).count();%0A    %7D%0A%0A    static class ParsedData%3CE%3E %7B%0A        final String string;%0A        final E e;%0A%0A        ParsedData(String string, E e) %7B%0A            this.string = string;%0A            this.e = e;%0A        %7D%0A    %7D%0A%7D%0A

Add the ability to cache the results parsed from a CharSequence.