Skip to content

Commit

Permalink
Minor improvements to InMemoryTokenCache
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfurmanski committed Jan 7, 2019
1 parent 5aaf8a5 commit 52edd6c
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -26,6 +26,8 @@
import org.neo4j.kernel.impl.util.CopyOnWriteHashMap;
import org.neo4j.storageengine.api.Token;

import static java.util.Collections.unmodifiableCollection;

/**
* Token cache that provide id -> TOKEN and name -> id mappings.
* Name -> id mapping will be updated last since it's used as part of the check for token existence in a cache.
Expand Down Expand Up @@ -54,7 +56,7 @@ public void clear()
idToToken.clear();
}

private void putAndEnsureUnique( Map<String,Integer> nameToId, Token token, String tokenType )
private void putAndEnsureUnique( Map<String,Integer> nameToId, TOKEN token, String tokenType )
{
Integer previous = nameToId.putIfAbsent( token.name(), token.id() );
if ( previous != null && previous != token.id() )
Expand Down Expand Up @@ -98,7 +100,7 @@ public TOKEN getToken( int id )

public Iterable<TOKEN> allTokens()
{
return idToToken.values();
return unmodifiableCollection( idToToken.values() );
}

public int size()
Expand Down

0 comments on commit 52edd6c

Please sign in to comment.