Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize file reading by switching to stream-based comment filtering #1

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

deepdik
Copy link
Owner

@deepdik deepdik commented Nov 14, 2024

  • Replaced Files.readAllLines() with Files.lines() to enable lazy loading, improving memory efficiency and performance, especially for large files.
  • Added a try-with-resources block to ensure the stream is closed automatically after use.
  • Streamlined comment filtering by processing lines directly and joining them into a single string without intermediate storage.

This optimization minimizes memory usage and enhances performance by avoiding the overhead of loading the entire file into memory at once.

- Replaced `Files.readAllLines()` with `Files.lines()` to enable lazy loading, improving memory efficiency and performance, especially for large files.
- Added a try-with-resources block to ensure the stream is closed automatically after use.
- Streamlined comment filtering by processing lines directly and joining them into a single string without intermediate storage.

This optimization minimizes memory usage and enhances performance by avoiding the overhead of loading the entire file into memory at once.
@deepdik deepdik merged commit 3e3bb37 into master Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant