Skip to content

Commit e0ef639

Browse files
committed
Restored changes for MemoizeFunction.
1 parent e882faf commit e0ef639

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/com/github/underscore/MemoizeFunction.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ public abstract class MemoizeFunction<F, T> implements Function<F, T> {
99
public abstract T calc(final F n);
1010

1111
public T apply(final F key) {
12-
final T value = calc(key);
13-
cache.putIfAbsent(key, value);
14-
return value;
12+
if (!cache.containsKey(key)) {
13+
cache.put(key, calc(key));
14+
}
15+
return cache.get(key);
1516
}
1617
}

0 commit comments

Comments
 (0)