Loading ...
Sorry, an error occurred while loading the content.

118033Re: Adding items'List to items'List2

Expand Messages
  • Benjamin R. Haskell
    Oct 6, 2010
      On Wed, 6 Oct 2010, ZyX wrote:

      > Ответ на сообщение <<Re: Adding items'List to items'List2>>, присланное
      > в 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.

      "Why"? = unaware that Vimscript, unlike many langs, doesn't store the
      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

      :echo strlen("foo\x00bar")
      :echo strlen("foo".nr2char(0)."bar")

      (( 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
    • Show all 5 messages in this topic