[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.4.2 New assorted suggestions
- From: Andrew Gierth <andrew@...>
- Date: Mon, 16 Nov 2020 01:16:48 +0000
>>>>> "Ranier" == Ranier Vilela <ranier.vf@gmail.com> writes:
Ranier> - if (strcmp(ar.namewhat, "method") == 0) {
Ranier> + if (strncmp(ar.namewhat, "method", 6) == 0) {
That's obviously completely wrong, since it would then match any string
_starting with_ "method".
All your other examples of strncmp are wrong for the same reason.
Ranier> 4. Avoid strlen at lua_pushstring, with a constant "k".
Ranier> - lua_pushstring(L, "k");
Ranier> + lua_pushlstring(L, "k", 1);
This really isn't likely to be worth it.
Ranier> 5. fgets returns char * pointer which needs to be compared to
Ranier> NULL, not 0.
0 is a valid way to say "the null pointer".
Ranier> Strchr is it's more efficient than strcmp.
It also does something completely different, which is not applicable
here.
--
Andrew.