Is the new map function for compute slower than using a combination of containsKey, get and put
counter.compute(tree[j], (k, v) -> {
if (v == null) {
v = 0;
}
return v + 1;
});
I tend to use containsKey, get and put in this combination
if (counter.containsKey(tree[j])) {
counter.put(tree[j], counter.get(tree[j] + 1);
}
else {
counter.put(tree[j], 1);
}
I feel that compute tends to work a bit slower but I don't know how to benchmark to actually understand the performance difference