I have about 40 entries in my user-list.
The time taken makes more sense now given the loops involved.
How about a true/false flag indicating whether there are any nick colour entries related to idle times at all? If not set, skip the 30-seconds check. Somewhat of a hack, but I'm willing to bet that most people don't use a combination of idletime-based and userlevel-based nick colouring...
I'd agree with this. In my case, I only use user-level's for nick colors. So the extra tests within the loop aren't needed at all.
As for speeding it up, as user's addresses are available upon most events, would it be possible to 'cache' the matched entries, and thus only loop through the smaller subset.
Admittedly, this would make the JOIN/PART/QUIT/MODE/NICK events more difficult, but could possibly be tied to the IAL routines.
Notification of changes to the user-list could get nasty though..
I suppose the other approach would be to flatten/amalgamate the entire nick color list into a mask, so only one loop-iteration total would be required of the 4000, ignoring tests for the unselected/unused options. For those that match the big-mask in any manner, do finer grained tests and actions if required.