Repository navigation
perf: Eliminate Stream allocations in Env getters - #87
#87Merged
kawasima merged 1 commit intoMar 8, 2026
developenkan/enkan:developfrom
perf/ env- eliminate- stream- allocenkan/enkan:perf/env-eliminate-stream-allocCopy head branch name to clipboard
Merged
kawasima merged 1 commit intodevelopenkan/enkan:developfrom perf/ env- eliminate- stream- allocenkan/enkan:perf/env-eliminate-stream-allocCopy head branch name to clipboard
kawasima merged 1 commit into
developenkan/enkan:developfrom
perf/ env- eliminate- stream- allocenkan/enkan:perf/env-eliminate-stream-allocCopy head branch name to clipboard
Conversation
Replace Stream.of(...).map(...).filter(...).findFirst().orElse(...) with a direct envMap.get(normalizeKey(name)) lookup in all four typed getters (getString, getInt, getLong, getBoolean). Removes per-call Stream/Spliterator/Optional allocations. Behaviour is identical. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This is a targeted performance improvement that eliminates unnecessary Stream allocations in Env's four typed getter methods (getString, getInt, getLong, getBoolean). Previously, each call created a Stream/Spliterator object pipeline for what is effectively a single key lookup. The replacement is a direct envMap.get(normalizeKey(name)) call with a null check, preserving identical behavior while reducing per-call allocations.
Changes:
- Replaced
Stream.of(...).map(...).filter(...).findFirst().orElse(...)pipelines in all four typed getters with direct map lookups and null-conditional expressions - Removed the now-unused
import java.util.stream.Stream
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
None yet
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You can’t perform that action at this time.
Summary
Stream.of(...).map(...).filter(...).findFirst().orElse(...)with directenvMap.get(normalizeKey(name))lookup in all four typed getters (getString,getInt,getLong,getBoolean)import java.util.stream.Streamandimport java.util.ObjectsNumberFormatExceptionstill propagates fromgetInt/getLongCloses #86
Test plan
mvn test -pl enkan-core— all 8 existingEnvTesttests pass🤖 Generated with Claude Code