src/jdk.jfr/share/classes/jdk/jfr/consumer/ConstantLookup.java
author egahlin
Thu, 11 Jul 2019 02:21:18 +0200
branchJEP-349-branch
changeset 57467 de154169948b
parent 57361 53dccc90a5be
child 57985 be121cbf3284
permissions -rw-r--r--
Enable constant pool caching

package jdk.jfr.consumer;

import jdk.jfr.internal.Type;

final class ConstantLookup {

    private final Type type;
    private ConstantMap current;
    private ConstantMap previous = ConstantMap.EMPTY;

    ConstantLookup(ConstantMap current, Type type) {
        this.current = current;
        this.type = type;
    }

    public Type getType() {
        return type;
    }

    public ConstantMap getLatestPool() {
        return current;
    }

    public void newPool() {
        previous = current;
        current = new ConstantMap(current.factory, current.name);
     //   previous =  new ConstantMap(); // disable cache
    }

    public Object getPreviousResolved(long key) {
        return previous.getResolved(key);
    }

    public Object getCurrentResolved(long key) {
        return current.getResolved(key);
    }

    public Object getCurrent(long key) {
        return current.get(key);
    }

}