Skip to content

Commit ba6ad5f

Browse files
committed
optimize Optional
1 parent c515983 commit ba6ad5f

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

core/src/main/java/fj/data/optic/Optional.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,7 @@ public <L> F<S, Either<L, S>> modifyEitherF(final F<A, Either<L, A>> f) {
206206

207207
@Override
208208
public F<S, IO<S>> modifyIOF(final F<A, IO<A>> f) {
209-
return s -> getOrModify(s).either(
210-
IOFunctions::unit,
211-
t -> IOFunctions.<A, S> map(f.f(t), b -> set.f(b).f(s))
212-
);
209+
return s -> getOption.f(s).option(IOFunctions.unit(s), a -> IOFunctions.<A, S> map(f.f(a), b -> set.f(b).f(s)));
213210
}
214211

215212
@Override
@@ -278,7 +275,7 @@ public F<S, V2<S>> modifyV2F(final F<A, V2<A>> f) {
278275

279276
@Override
280277
public F<S, S> modify(final F<A, A> f) {
281-
return s -> getOrModify(s).either(Function.identity(), a -> set.f(f.f(a)).f(s));
278+
return s -> getOption.f(s).option(s, a -> set.f(f.f(a)).f(s));
282279
}
283280

284281
});

0 commit comments

Comments
 (0)