perf(epub): Replace linear manifest scans with HashMaps in EPUB reader #2598
+92
−49
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.
🚀 Pull Request
📝 Description
Minor refactor for Epub reading service to improve code quality, and performance.
🛠️ Changes Implemented
1. Pre-computed lookup structures
validPathsSet for O(1) path validation (previously O(n) stream filter)manifestByHrefMap for O(1) manifest item lookup by href2. Thread-local DocumentBuilder
3. Optimized content type detection
lastIndexOf+substring4. I/O buffering
5. Cache management
touch()method to update last accessed timePerformance Impact
🧪 Testing Strategy
📸 Visual Changes (if applicable)
Please Read - This Checklist is Mandatory
Mandatory Requirements (please check ALL boxes):
developbranch (please resolve any merge conflicts)./gradlew testfor Spring Boot backend, andng testfor Angular frontend - NO EXCEPTIONS)Why This Matters:
Recent production incidents have been traced back to:
Backend changes without tests will not be accepted. By completing this checklist thoroughly, you're helping maintain the quality and stability of Booklore for all users.
Note to Reviewers: Please verify the checklist is complete before beginning your review. If items are unchecked, kindly ask the contributor to complete them first.
💬 Additional Context (optional)