⚡ Optimize keyword extraction to reduce allocations#98
Conversation
- Removed repeated allocations for string cloning, concatenation, and full-text lowercasing. - Implemented zero-allocation iterator-based word splitting and filtering. - Used `eq_ignore_ascii_case` for common word filtering to avoid allocating lowercase strings for common words. - Added `Vec::with_capacity` heuristic to reduce reallocations. - Verified with existing tests and custom benchmark (approx 1.2x speedup on small inputs). Co-authored-by: myaple <10523487+myaple@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Optimized the
extract_keywordsfunction insrc/repo_context.rsto reduce memory allocations and improve performance. The original implementation involved cloning the title, concatenating the description, converting the entire text to lowercase, and allocating strings for every word before filtering. The new implementation iterates over the original text slices, checks for common words using case-insensitive comparison without allocation, and only allocates memory for valid keywords. This results in reduced GC pressure and improved CPU efficiency.PR created automatically by Jules for task 3310153023293674752 started by @myaple