Skip to content

Commit

Permalink
Use computeIfAbsent for stringCache
Browse files Browse the repository at this point in the history
  • Loading branch information
steffenaxer committed Mar 13, 2024
1 parent 6aa1deb commit 5f4ad5e
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@
*/
public class StringConverter implements AttributeConverter<String> {
private final Map<String, String> stringCache = new ConcurrentHashMap<>(1000);

@Override
public String convert(String value) {
String s = this.stringCache.get(value);
if (s == null) {
s = value;
this.stringCache.put(s, s);
}
return s;
return stringCache.computeIfAbsent(value, k -> k);
}

@Override
Expand Down

0 comments on commit 5f4ad5e

Please sign in to comment.