[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: String equality?
- From: "Mark Meijer" <meijer78@...>
- Date: Mon, 05 Dec 2005 08:23:24 +0000
You could always combine the pointer equality and strcmp() (and/or other
methods of equality testing), e.g:
char* myFoo = "foo";
char* prop = lua_tostring(L, -1);
if((prop == myFoo) || (strcmp(prop, myFoo) == 0))
[...]
Obviously if the pointers are equal then you are sure the strings are equal,
so there's no harm in using this to your advantage (without relying solely
on this) if chances are good that you can prevent the strcmp that way (or
any other performance hits that other approaches impose).
Greets,
Mark