Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*=================================================================
- _ ____ _____ __ __
- (_) _ \ ___ |_ _|__ __ _| \/ |
- | | |_) / __| | |/ _ \/ _` | |\/| |
- | | __/\__ \ | | __/ (_| | | | |
- |_|_| |___/ |_|\___|\__,_|_| |_|
- Created by Bruno da Silva
- www.ips-team.blogspot.com
- Fasthest check string with case/switch
- =================================================================*/
- #define switchStr(%0) switch(dracoHash(%0))
- #define string<%0> dracoHash(#%0)
- new s1 = 1;
- new s2 = 0;
- new length;
- stock dracoHash(buf[])
- {
- length = strlen(buf);
- s1 = 1, s2 = 0;
- for (new n; n < length; ++n)
- {
- s1 = (s1 + buf[n]) % 65521;
- s2 = (s2 + s1) % 65521;
- }
- return (s2 << 16) + s1;
- }
- // =========== [ Example ] =========
- switchStr("drakins")
- {
- case string<drakon>:
- {
- print("is drakon");
- }
- case string<drakins>:
- {
- print("is drakins");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement