diff options
author | ZyX <kp-pav@yandex.ru> | 2016-02-11 01:34:08 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2016-04-18 02:47:13 +0300 |
commit | 209427e97224ea7fdd49eb53fa41e0b26c55369f (patch) | |
tree | 1ef493e05b676fd1fe10cff21b2b4141393b19f5 /src | |
parent | f0bd4a149408e75ebf887530964e0948518938dc (diff) | |
download | rneovim-209427e97224ea7fdd49eb53fa41e0b26c55369f.tar.gz rneovim-209427e97224ea7fdd49eb53fa41e0b26c55369f.tar.bz2 rneovim-209427e97224ea7fdd49eb53fa41e0b26c55369f.zip |
eval/encode: Reduce length of encode_list_write
Changes suggested by oni-link.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval/encode.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 6fa22bfc5c..4d6a0afe9c 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -72,9 +72,6 @@ int encode_list_write(void *data, const char *buf, size_t len) list_T *const list = (list_T *) data; const char *const end = buf + len; const char *line_end = buf; - if (list->lv_last == NULL) { - list_append_string(list, NULL, 0); - } listitem_T *li = list->lv_last; do { const char *line_start = line_end; @@ -94,11 +91,7 @@ int encode_list_write(void *data, const char *buf, size_t len) memcpy(str, line_start, line_length); str[line_length] = 0; } - for (size_t i = 0; i < line_length; i++) { - if (str[i] == NUL) { - str[i] = NL; - } - } + memchrsub(str, NUL, NL, line_length); } if (li == NULL) { list_append_allocated_string(list, str); |