Isnull
From SA-MP Wiki
isnull
Note: This function name starts with a lowercase letter. |
Description:
Checks whether a string is null (empty). More efficient than checking if strlen is 0.
(string)
string | The string to check for emptiness |
Definition:
#if !defined isnull #define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1])))) #endif
Example Usage:
if(isnull(string)) { // Do something }
Tip | isnull is more efficient than strlen() because isnull simply checks if the first character of a string is the null-terminator (end of string), while strlen goes through every character of the string.
They are almost identical if the string IS empty, but if it is not then strlen has to go through every single character (which could be thousands) until it reaches the end. |