Skip to content

Commit

Permalink
Use map() and orElse() instead of ifPresent() and get() in setup of d…
Browse files Browse the repository at this point in the history
…rawbuffers/rendertargets
  • Loading branch information
Justsnoopy30 committed Dec 12, 2021
1 parent 3f5d382 commit 4527c98
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/main/java/net/coderbot/iris/shaderpack/ProgramDirectives.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
import net.coderbot.iris.gl.blending.AlphaTestOverride;
import net.coderbot.iris.gl.blending.BlendModeOverride;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.Nullable;

import javax.swing.text.html.Option;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;

public class ProgramDirectives {
private static final ImmutableList<String> LEGACY_RENDER_TARGETS = PackRenderTargetDirectives.LEGACY_RENDER_TARGETS;
Expand All @@ -40,18 +37,15 @@ public class ProgramDirectives {
Optional<CommentDirective> optionalRendertargetsDirective = findRenderTargetDirective(source.getFragmentSource());

Optional<CommentDirective> optionalCommentDirective = getAppliedDirective(optionalDrawbuffersDirective, optionalRendertargetsDirective);
if (optionalCommentDirective.isPresent()) {
CommentDirective commentDirective = optionalCommentDirective.get();
drawBuffers = optionalCommentDirective.map((commentDirective) -> {
if (commentDirective.getType() == CommentDirective.Type.DRAWBUFFERS) {
drawBuffers = parseDigits(commentDirective.getDirective().toCharArray());
return parseDigits(commentDirective.getDirective().toCharArray());
} else if (commentDirective.getType() == CommentDirective.Type.RENDERTARGETS) {
drawBuffers = parseDigitList(commentDirective.getDirective());
return parseDigitList(commentDirective.getDirective());
} else {
throw new IllegalStateException("Unhandled comment directive type!");
}
} else {
drawBuffers = new int[] { 0 };
}
}).orElse(new int[] { 0 });

if (properties != null) {
viewportScale = properties.getViewportScaleOverrides().getOrDefault(source.getName(), 1.0f);
Expand Down

0 comments on commit 4527c98

Please sign in to comment.