Repository navigation
Conversation
Move `field_re` compilation out of `_regex_struct_fields` to the class level to avoid compiling it on every invocation. Additionally, optimize the inline `re.search` loop condition by hoisting it to a class level compiled regex as well. Co-authored-by: godofecht <[email protected]>
|
👋 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. |
625f7d0 to
b49015a
Compare
Understood. Acknowledging that this work is now obsolete and stopping work on this task. |
💡 What:
The regex used to parse struct fields (
field_re) inFlowLanguageServer._regex_struct_fieldswas being compiled dynamically every time the method was called. Similarly, a regex loop condition (re.search(r'^\s*\}', row)) was being evaluated dynamically inside the method's loop.This PR lifts both of these regexes up to the
FlowLanguageServerclass scope so that they are compiled exactly once when the module loads, instead of repetitively on every method invocation or loop iteration.🎯 Why:
The
_regex_struct_fieldsmethod is used as a fallback mechanism for LSP symbol generation. Since regex string compilation carries a non-trivial baseline overhead in Python, repetitive compilation inside loops or repeatedly called methods unnecessarily wastes CPU cycles and slows down language server responsiveness.📊 Measured Improvement:
Using
timeitviabench_lsp_regex.py(parsing a small mock 2-struct file with 100,000 iterations):PR created automatically by Jules for task 773527547509198172 started by @godofecht