118033Re: Adding items'List to items'List2
- Oct 6, 2010On Wed, 6 Oct 2010, ZyX wrote:
> Ответ на сообщение <<Re: Adding items'List to items'List2>>, присланное"Why"? = unaware that Vimscript, unlike many langs, doesn't store the
> в 23:18:25 06 октября 2010, Среда. Отправитель: Benjamin R. Haskell:
> Why you are using `strlen()'? Vim neither stores string length
> alongside with string nor recognizes when `strlen' is used in boolean
> context, so using `empty()' or `()==#""' is better as it does not
> require to loop over the entire string for a null byte.
string length. Also didn't realize that strings can't have null bytes
(which is often what the strlen() optimization allows for in the first
(( explained right above ':help literal-string' ("Note that "\000" and
"\x00" force the end of the string"), and in ':help nr2char()' ))
I guess it's only surprising because I thought the whole point of the
odd \r/\n behavior in s/// was to support null bytes, and didn't realize
it was only for buffers (not for strings).
Upshot: 'empty(v:val)' or 'v:val == ""' is better. (Any particular
reason to use '==#', seeing as how the case of "" doesn't matter?)
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
- << Previous post in topic Next post in topic >>