optimized O(n²) pool lookup to O(n) with Map in getPoolsBorrow#2716
optimized O(n²) pool lookup to O(n) with Map in getPoolsBorrow#2716adityamane765 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR optimizes the ChangesPool lookup optimization
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
getPoolsBorrow was calling pools.find() inside a .map() over lendBorrow -> resulting in O(n²) comparisons on every request. With thousands of pools on both sides this means millions of string comparisons per call. Replaced with a Map keyed by pool id built once before the loop, reducing the join to O(n).
Summary by CodeRabbit