From a33f20d690becc86ce2b70a57de020ebd169d84e Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Thu, 6 Oct 2016 18:41:57 -0700 Subject: [PATCH] Update ycmd, and use JoinLinesAsUnicode in GetUnsavedAndCurrentBufferData(). This function is invoked on every kepress. On a large file (15+k loc), using this new function takes kepress latency down to <10ms from ~100ms. --- python/ycm/tests/vimsupport_test.py | 2 +- python/ycm/vimsupport.py | 4 ++-- third_party/ycmd | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/ycm/tests/vimsupport_test.py b/python/ycm/tests/vimsupport_test.py index ac72d326..785a948a 100644 --- a/python/ycm/tests/vimsupport_test.py +++ b/python/ycm/tests/vimsupport_test.py @@ -1407,7 +1407,7 @@ def GetUnsavedAndCurrentBufferData_EncodedUnicodeCharsInBuffers_test( *args ): mock_buffer = MagicMock() mock_buffer.name = os.path.realpath( 'filename' ) mock_buffer.number = 1 - mock_buffer.__iter__.return_value = [ u'abc', ToBytes( u'fДa' ) ] + mock_buffer.__iter__.return_value = [ ToBytes ( u'abc' ), ToBytes( u'fДa' ) ] with patch( 'vim.buffers', [ mock_buffer ] ): assert_that( vimsupport.GetUnsavedAndCurrentBufferData(), diff --git a/python/ycm/vimsupport.py b/python/ycm/vimsupport.py index 6ebf1315..068922d4 100644 --- a/python/ycm/vimsupport.py +++ b/python/ycm/vimsupport.py @@ -30,7 +30,7 @@ import tempfile import json import re from collections import defaultdict -from ycmd.utils import ToUnicode, ToBytes +from ycmd.utils import ToUnicode, ToBytes, JoinLinesAsUnicode from ycmd import user_options_store BUFFER_COMMAND_MAP = { 'same-buffer' : 'edit', @@ -125,7 +125,7 @@ def GetUnsavedAndCurrentBufferData(): buffers_data[ GetBufferFilepath( buffer_object ) ] = { # Add a newline to match what gets saved to disk. See #1455 for details. - 'contents': '\n'.join( ToUnicode( x ) for x in buffer_object ) + '\n', + 'contents': JoinLinesAsUnicode( buffer_object ) + '\n', 'filetypes': FiletypesForBuffer( buffer_object ) } diff --git a/third_party/ycmd b/third_party/ycmd index 36350644..f3232ce5 160000 --- a/third_party/ycmd +++ b/third_party/ycmd @@ -1 +1 @@ -Subproject commit 363506449fe18337b6aabbf29d8a14720483ccf6 +Subproject commit f3232ce5180753822d839c80e9b9ea4e33e89d4c