A bit of a debate (you make life difficult mezzanine! But I can't help but <3 you) has raised over how I do the binds in my horoscope script, using a mass [foreach] to bind all the signs to pub and msg binds. This, obviously, creates a very large [binds] list.
The alternative is using a * pubm/msgm and checking each line of text against every bind (I foresee another foreach and regexp/string matching), on every single line of text that is said. This is basically what eggdrop does anyway, no? Checking each line against it's binds list.
So I'm wondering what do you think would yield better performance, using individual binds and letting eggdrop do the work, or using pubm and checking the binds on the script level? Consider large/small channels etc, or bots on many channels.
Interesting subject. Lets try to analyze this theoretically (this is only my assumption and is not necessarily true); When using a pub bind, Eggdrop does actually do the matching but I suppose it's faster than matching using Tcl in a pubm procedure. However, a huge [binds] list means more memory usage but that shouldn't be an issue if we're just talking about what? 50 binds maximum? so, in my opinion, even in a large channel with much traffic... using pub would be better in terms of performance than pubm... but that should be put for testing of course.
Basically the main example would be my horoscope script, and in 3.0 you can set multiple commands chars, and with the option to bind signs (sorry not bragging here >_>), this adds up to 50ish binds or so (with 2 commands chars).
so we're talking 50 to 100 binds? how much memory does that take up? not more than 2 or 3KB if I'm not mistaken so that's not at all to be considered as a load.
Well, 50 with 2 command chars (most people will use 1). Let's just say anyway that your eggdrop had 100 binds active.
If eggdrop is doing it, I picture eggdrop running a big foreach {} kind of thing against all the binds it has stored. If you start using pubm and binding to *, then you start having nested foreach {}'s, while eggdrop loops through its bind list, and then a foreach in your script to check the binds, and then back into the eggdrop loop, etc. I can't help but think it would be most optimized by having eggdrop do as much of the work as possible.
Actually, all eggdrop does is iterate through a linked list of structs. The speed of this cannot be matched by any construction in tcl involving any kind of loops.
As for the memory consumption, the footprint of the structs would not be considderably larger than the footprint of the proc that would do the "msgm/pubm version".
Personally, the only "issue" I could possibly see with using multiple msg/pub bindings, is that they do not stack, whereas msgm/pubm does. Unless you think seeing 50-100 extra lines when using the .binds command is an issue