Auto merge of #2370 - jlebar:JoinLinesAsUnicode, r=micbou

Use JoinLinesAsUnicode in GetUnsavedAndCurrentBufferData().

# PR Prelude

Thank you for working on YCM! :)

**Please complete these steps and check these boxes (by putting an `x` inside
the brackets) _before_ filing your PR:**

- [ x ] I have read and understood YCM's [CONTRIBUTING][cont] document.
- [ x ] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
- [ x ] I have included tests for the changes in my PR. If not, I have included a
  rationale for why I haven't.

Rationale: Tests are in https://github.com/Valloric/ycmd/pull/617.  This does not change any behavior in YCM itself, only makes things go faster.

- [ x ] **I understand my PR may be closed if it becomes obvious I didn't
  actually perform all of these steps.**

# Why this change is necessary and useful

GetUnsavedAndCurrentBufferData() is invoked on every kepress.  On a large file (15+k loc), using this new function takes kepress latency down to <10ms from ~100ms.

The function used here is added to ycmd in https://github.com/Valloric/ycmd/pull/617.  I will update this PR to include a ycmd submodule update if and when that PR is merged.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2370)
<!-- Reviewable:end -->
This commit is contained in:
Homu 2016-10-08 17:51:18 +09:00
commit b6d5af3424
3 changed files with 4 additions and 4 deletions

View File

@ -1407,7 +1407,7 @@ def GetUnsavedAndCurrentBufferData_EncodedUnicodeCharsInBuffers_test( *args ):
mock_buffer = MagicMock() mock_buffer = MagicMock()
mock_buffer.name = os.path.realpath( 'filename' ) mock_buffer.name = os.path.realpath( 'filename' )
mock_buffer.number = 1 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 ] ): with patch( 'vim.buffers', [ mock_buffer ] ):
assert_that( vimsupport.GetUnsavedAndCurrentBufferData(), assert_that( vimsupport.GetUnsavedAndCurrentBufferData(),

View File

@ -30,7 +30,7 @@ import tempfile
import json import json
import re import re
from collections import defaultdict from collections import defaultdict
from ycmd.utils import ToUnicode, ToBytes from ycmd.utils import ToUnicode, ToBytes, JoinLinesAsUnicode
from ycmd import user_options_store from ycmd import user_options_store
BUFFER_COMMAND_MAP = { 'same-buffer' : 'edit', BUFFER_COMMAND_MAP = { 'same-buffer' : 'edit',
@ -125,7 +125,7 @@ def GetUnsavedAndCurrentBufferData():
buffers_data[ GetBufferFilepath( buffer_object ) ] = { buffers_data[ GetBufferFilepath( buffer_object ) ] = {
# Add a newline to match what gets saved to disk. See #1455 for details. # 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 ) 'filetypes': FiletypesForBuffer( buffer_object )
} }

2
third_party/ycmd vendored

@ -1 +1 @@
Subproject commit 363506449fe18337b6aabbf29d8a14720483ccf6 Subproject commit f3232ce5180753822d839c80e9b9ea4e33e89d4c