perf: optimize SQL editor typing performance#16
Conversation
- Pre-compile 21 regex patterns in SQLContextAnalyzer as static properties (eliminates regex compilation on every autocomplete call) - Add smart view invalidation in EditorTextView to only redraw affected line regions instead of full view on every keystroke
There was a problem hiding this comment.
Pull request overview
This PR optimizes SQL editor typing performance by pre-compiling regex patterns and implementing smart view invalidation to reduce unnecessary redraws.
- Pre-compiled 21 regex patterns as static properties in SQLContextAnalyzer to eliminate repeated compilation overhead
- Implemented line-based invalidation in EditorTextView to redraw only affected line regions instead of the full view
- Added ALTER TABLE column context detection with new
alterTableColumnclause type
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| TablePro/Views/Editor/EditorTextView.swift | Implements smart line-based invalidation with cursor tracking to minimize redraw regions, replacing full view redraws |
| TablePro/Core/Autocomplete/SQLContextAnalyzer.swift | Pre-compiles 21 regex patterns as static properties and adds ALTER TABLE context extraction for improved autocomplete performance |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 12 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
Summary
Fix SQL editor typing lag by implementing two key optimizations.
Changes
1. SQLContextAnalyzer.swift - Pre-compile regex patterns
Pre-compiled 21 regex patterns as static properties instead of compiling on every autocomplete call:
Impact: Eliminates ~21 regex compilations per autocomplete trigger.
2. EditorTextView.swift - Smart view invalidation
Replaced full view redraw with smart line-based invalidation:
Impact: Reduces GPU work from full-view redraw to only 1-2 line regions.
Testing