Using 'dup':1 to save expensive dup eliminition
Since we are never going to return duplicate candidates to Vim we might as well save some performance by forcing Vim to not search for duplicates
This commit is contained in:
parent
7bf18c7c5c
commit
b53ea06d5f
@ -23,7 +23,7 @@ import indexer
|
|||||||
|
|
||||||
MIN_NUM_CHARS = int( vim.eval( "g:ycm_min_num_of_chars_for_completion" ) )
|
MIN_NUM_CHARS = int( vim.eval( "g:ycm_min_num_of_chars_for_completion" ) )
|
||||||
CLANG_FILETYPES = set( [ 'c', 'cpp', 'objc', 'objcpp' ] )
|
CLANG_FILETYPES = set( [ 'c', 'cpp', 'objc', 'objcpp' ] )
|
||||||
MAX_IDENTIFIER_COMPLETIONS_RETURNED = 20
|
MAX_IDENTIFIER_COMPLETIONS_RETURNED = 10
|
||||||
|
|
||||||
|
|
||||||
class Completer( object ):
|
class Completer( object ):
|
||||||
@ -94,7 +94,14 @@ class IdentifierCompleter( Completer ):
|
|||||||
def CandidatesFromStoredRequest( self ):
|
def CandidatesFromStoredRequest( self ):
|
||||||
if not self.future:
|
if not self.future:
|
||||||
return []
|
return []
|
||||||
return self.future.GetResults()[ : MAX_IDENTIFIER_COMPLETIONS_RETURNED ]
|
completions = self.future.GetResults()[
|
||||||
|
: MAX_IDENTIFIER_COMPLETIONS_RETURNED ]
|
||||||
|
|
||||||
|
# We will never have duplicates in completions so with 'dup':1 we tell Vim
|
||||||
|
# to add this candidate even if it's a duplicate of an existing one (which
|
||||||
|
# will never happen). This saves us some expensive string matching
|
||||||
|
# operations in Vim.
|
||||||
|
return [ { 'word': x, 'dup': 1 } for x in completions ]
|
||||||
|
|
||||||
|
|
||||||
class ClangCompleter( Completer ):
|
class ClangCompleter( Completer ):
|
||||||
@ -162,6 +169,7 @@ def CompletionDataToDict( completion_data ):
|
|||||||
'abbr' : completion_data.original_string_,
|
'abbr' : completion_data.original_string_,
|
||||||
'menu' : completion_data.extra_menu_info_,
|
'menu' : completion_data.extra_menu_info_,
|
||||||
'kind' : completion_data.kind_,
|
'kind' : completion_data.kind_,
|
||||||
|
'dup' : 1,
|
||||||
# TODO: add detailed_info_ as 'info'
|
# TODO: add detailed_info_ as 'info'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user