Description
The key of MongoMK.nodeCache and nodeChildrenCache is currently a String, whose evaluation is somewhat expensive:
path + "@" + rev
In the above code, "rev.toString()" internally creates another StringBuilder to generate another intermediate string. The attached screenshot shows that around 5% of profiling time within "MongoMK.getNode()" is wasted in order to calculate the caching key. Other methods are also affected.
A simple way to improve this is to reuse a single StringBuilder for the key, as such:
StringBuilder sb = new StringBuilder(); sb.append(path); sb.append("@"); rev.appendTo(sb);
A better way would probably be to wrap "path" and "rev" in another re-usable "NodeRev" object to be used instead of using two references "path" and "rev". The "NodeRev" object would provide appropriate equals() and hashCode() implementations.