Getting rid of Computable and Function in lazy values and memoized functions

This commit is contained in:
Andrey Breslav
2013-10-04 19:17:10 +04:00
committed by Alexander Udalov
parent 4d28dfada6
commit 7d1c46ed2c
27 changed files with 103 additions and 131 deletions
@@ -181,11 +181,6 @@ public class LockBasedStorageManager implements StorageManager {
@Override
public T invoke() {
return compute();
}
@Override
public T compute() {
Object _value = value;
if (!(value instanceof NotValue)) return WrappedValues.unescapeThrowable(_value);
@@ -245,8 +240,8 @@ public class LockBasedStorageManager implements StorageManager {
@Override
@NotNull
public T compute() {
T result = super.compute();
public T invoke() {
T result = super.invoke();
assert result != null : "compute() returned null";
return result;
}
@@ -263,14 +258,9 @@ public class LockBasedStorageManager implements StorageManager {
this.compute = compute;
}
@Override
public V invoke(K k) {
return fun(k);
}
@Override
@Nullable
public V fun(@NotNull K input) {
public V invoke(@NotNull K input) {
Object value = cache.get(input);
if (value != null) return WrappedValues.unescapeExceptionOrNull(value);
@@ -311,8 +301,8 @@ public class LockBasedStorageManager implements StorageManager {
@NotNull
@Override
public V fun(@NotNull K input) {
V result = super.fun(input);
public V invoke(@NotNull K input) {
V result = super.invoke(input);
assert result != null : "compute() returned null";
return result;
}
@@ -16,15 +16,10 @@
package org.jetbrains.jet.storage;
import com.intellij.util.Function;
import jet.Function1;
import org.jetbrains.annotations.NotNull;
public interface MemoizedFunctionToNotNull<P, R> extends Function<P, R>, Function1<P, R> {
@Override
@NotNull
R fun(P p);
public interface MemoizedFunctionToNotNull<P, R> extends Function1<P, R> {
@Override
@NotNull
R invoke(P p);
@@ -16,15 +16,10 @@
package org.jetbrains.jet.storage;
import com.intellij.util.Function;
import jet.Function1;
import org.jetbrains.annotations.Nullable;
public interface MemoizedFunctionToNullable<P, R> extends Function<P, R>, Function1<P, R> {
@Override
@Nullable
R fun(P p);
public interface MemoizedFunctionToNullable<P, R> extends Function1<P, R> {
@Override
@Nullable
R invoke(P p);
@@ -16,15 +16,10 @@
package org.jetbrains.jet.storage;
import com.intellij.openapi.util.Computable;
import jet.Function0;
import org.jetbrains.annotations.NotNull;
public interface NotNullLazyValue<T> extends Computable<T>, Function0<T> {
@Override
@NotNull
T compute();
public interface NotNullLazyValue<T> extends Function0<T> {
@Override
@NotNull
T invoke();
@@ -16,15 +16,10 @@
package org.jetbrains.jet.storage;
import com.intellij.openapi.util.Computable;
import jet.Function0;
import org.jetbrains.annotations.Nullable;
public interface NullableLazyValue<T> extends Computable<T>, Function0<T> {
@Override
@Nullable
T compute();
public interface NullableLazyValue<T> extends Function0<T> {
@Override
@Nullable
T invoke();