-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace endless if (** iswm ..) blocks with hash map #1
Comments
Might be. |
AFAIK, hash tables enable you to look up the value against a key quickly for large numbers of keys. I believe that you can iterate over the hash table too, though that is not their purpose. I am unsure how we can use a hash table for fast lookup of But if there is a way to use a hash table effectively let me know and I will code it. |
Hmmm - it seems that |
Good find, I didn't know about that $hfind() option. My initial idea was just looping over hashmap/items, to make filters more easier to maintain, compared to endless if statements. The hashmap should also contain the appropriate method to call on match, e.g.: |
Yes - we will need different hash tables for each group. I have this mostly done on my PC (but not yet on GitHub) - when I do the next commit it would be helpful if you could deskcheck old and new code to make sure that I have create a like for like solution. |
$hfind will be at least one order of magnitude more efficient/faster (and possibly two orders of magnitude) than a loop or list of if statements. |
It really depends. Hash map should be O(1), if Khaled has implemented it properly. However, since that $hfind() is a wildcard match on key, it probably loops internally and is O(n). |
Yes - but it will be machine code (C?) rather than interpreted mIRC script. |
I presume that mIRC compiles the script internally to bytecode/assembly-like on load and uses that. But you are probably right. We can always do a performance test if we really care... |
I don't really care TBH. It was performing OK on my PC as a list of IF statements. But I think using hashtables is both more elegant and more maintainable. |
Exactly. The if's just tickle my inner perfectionist in the wrong way. |
Coded - see #7 |
Might be faster to read filters from file/s into hashmaps and loop over hashmap, then take the appropriate action.
The text was updated successfully, but these errors were encountered: