Skip to content

Optimize performance of completion pipeline#302

Open
mattn wants to merge 3 commits into
masterfrom
optimize-performance
Open

Optimize performance of completion pipeline#302
mattn wants to merge 3 commits into
masterfrom
optimize-performance

Conversation

@mattn
Copy link
Copy Markdown
Collaborator

@mattn mattn commented Mar 20, 2026

asyncomplete#context() is called many times.

  • Avoid full asyncomplete#context() in textchangedp change detection; use lightweight line()/col()/getline() directly since only lnum/col/typed are needed for comparison
  • Build context dict directly from local variables instead of through intermediate dict key assignments
  • Replace exists('l:startcol') with a boolean flag (l:has_startcol) in s:on_change() to avoid reflection overhead
  • Skip s:strip_pair_characters() when base doesn't start with a pair character
  • Bulk-append items via += when base is empty instead of per-item add()
  • Use add(l:startcols, l:startcol) instead of l:startcols += [l:startcol] to avoid temporary list allocation
  • Fix redundant getcurpos() call in timer.vim s:maybe_notify_on_change(); reuse already-stored s:previous_position
  • Early return in asyncomplete#log() when log file is empty to reduce nesting

mattn added 3 commits March 20, 2026 19:01
- Replace exists('l:startcol') with a boolean flag in s:on_change()
- Avoid full asyncomplete#context() in textchangedp change detection; use lightweight line()/col()/getline() instead
- Build context dict directly from local vars instead of intermediate dict lookups
- Skip s:strip_pair_characters() call when base doesn't start with a pair character
- Bulk-append items when base is empty instead of per-item add
- Use add() instead of += [val] for startcols list building
- Fix redundant getcurpos() call in timer.vim s:maybe_notify_on_change()
- Early return in asyncomplete#log() when log file is empty
- Simplify s:should_skip() to single return expression
- Remove unused l:curitems variable in s:recompute_pum()
- Remove unused l:last_char variable in asyncomplete#_force_refresh()
- Use add() instead of += [val] for list appending consistently
- Use repeat() for bulk startcols fill instead of while loop
- Use l:trigger[-1:] instead of l:trigger[len(l:trigger) -1]
- Remove unused l:curitems variable in s:recompute_pum()
- Remove unused l:last_char variable in asyncomplete#_force_refresh()
- Use add() instead of += [val] for list appending consistently
- Use repeat() for bulk startcols fill instead of while loop
- Use l:trigger[-1:] instead of l:trigger[len(l:trigger) -1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant