20.02.2019, 18:19
Quote:
No:
1) Checking if a string is empty by using "strlen" is terrible, because if the string isn't empty it will take much longer. 2) Not all "null" strings are actually length zero. There is a bug in the PAWN VM which means you can't pass fully empty strings (actually, I don't think there is, but I thought there was when I wrote "CallRemoteFunction"). So instead of just "\0", it passes "\1\0" for empty strings. So if you use ZCMD and type a command with no parameters, "params" will have length 1, but "isnull" knows about this and will return true. |
So basically when one does CallRemoteFunction("myfunc", "s", ""), the native code will invoke myfunc but with a modified argument being "\1" instead (and the same for CallLocalFunction I assume), but except for these cases there's no real reason to use the common isnull everywhere instead of a 0 check on the first position, correct?
Fascinating how almost nobody seems to question things like this (or not publicly) and just 'do what everyone else does' (including the wiki, although that's perhaps because explaining this whole thing would be too confusing for the average scripter).