documentation: Update assert_{false,true}() and empty() documentation

Also removes a note regarding the performance of `empty(long_list)` vs
`len(long_list) == 0` because this has nothing to do with the actual state:
first checks that list is not NULL and pointer to its first element is also not
NULL, second gets length by comparing list with NULL and falls back to
`tv->vval.v_list->lv_len` if not. `len(long_list)` *may* still be *slightly*
slower, but the slow down has nothing to do with the length of the list, is
hardly noticeable and depends on how good compiler is at inlining and what
exactly have author of the plugin written (I mean `len(long_list) == 0` vs
`empty(long_list)` vs `!len(long_list)`).
This commit is contained in:
ZyX
2016-03-20 19:08:42 +03:00
parent 25bb08dad9
commit 9709cf2cdb

View File

@@ -2245,17 +2245,17 @@ assert_equal({expected}, {actual}, [, {msg}])
assert_false({actual}, [, {msg}]) *assert_false()* assert_false({actual}, [, {msg}]) *assert_false()*
When {actual} is not false an error message is added to When {actual} is not false an error message is added to
|v:errors|, like with |assert_equal()|.. |v:errors|, like with |assert_equal()|.
A value is false when it is zero. When "{actual}" is not a A value is false when it is zero or |v:false|. When "{actual}"
number the assert fails. is not a number or |v:false| the assert fails.
When {msg} is omitted an error in the form "Expected False but When {msg} is omitted an error in the form "Expected False but
got {actual}" is produced. got {actual}" is produced.
assert_true({actual}, [, {msg}]) *assert_true()* assert_true({actual}, [, {msg}]) *assert_true()*
When {actual} is not true an error message is added to When {actual} is not true an error message is added to
|v:errors|, like with |assert_equal()|.. |v:errors|, like with |assert_equal()|.
A value is true when it is a non-zeron number. When {actual} A value is true when it is a non-zero number or |v:true|.
is not a number the assert fails. When {actual} is not a number or |v:true| the assert fails.
When {msg} is omitted an error in the form "Expected True but When {msg} is omitted an error in the form "Expected True but
got {actual}" is produced. got {actual}" is produced.
@@ -2849,9 +2849,8 @@ diff_hlID({lnum}, {col}) *diff_hlID()*
empty({expr}) *empty()* empty({expr}) *empty()*
Return the Number 1 if {expr} is empty, zero otherwise. Return the Number 1 if {expr} is empty, zero otherwise.
A |List| or |Dictionary| is empty when it does not have any A |List| or |Dictionary| is empty when it does not have any
items. A Number is empty when its value is zero. items. A Number is empty when its value is zero. Special
For a long |List| this is much faster than comparing the variable is empty when it is |v:false| or |v:null|.
length with zero.
escape({string}, {chars}) *escape()* escape({string}, {chars}) *escape()*
Escape the characters in {chars} that occur in {string} with a Escape the characters in {chars} that occur in {string} with a