MOO-cows Mailing List Archive

[Prev][Next][Index][Thread]

Re: A few optimization questions...



Don Schwarz writes:
> things... First of all, is something like:
>   index("DF-BP-FC-BC-PP-PH-UL-IN", "BP")
> significantly faster than:
>   "BP" in {"DF", "BP", "FC", "BC", "PP", "PH", "UL", "IN"}

Yes, because the server is stupid and reconstructs that list of strings each
time this expression is evaluated.  If the list was already computed and, say,
stored in a property, then these two would be very close in speed.

> Also, is:
>   <some large string> in { <a list of about 25 equally large strings> }
> faster (and less CPU intensive) than:
>   string_hash( <some large string> ) in { <a list of 25 MD5 hashes> }

Good god, yes!  All of the MD5 functions are *much* slower than the other
simple operations.  Have you *seen* the complexity of that function?!

> And lastly, would it be worthwhile to write a special built-in function for
> something that runs approx. 10 times per call to $player:notify, to be used
> instead of:
>   match(foo, "%[%w%w:[a-zA-Z0-9:_]*%]")[1..2]

Gack!  It would be better to simply get rid of the necessity to do this on
every :notify.  It's not terrible, but it's not great, either.  Writing this as
a built-in would not be trivial, though.

	Pavel


Follow-Ups: References:

Home | Subject Index | Thread Index