jaytea commented on a Page, Nicklist colors  -  Jun 02, 2011

i was referring to the code in the comment, but similar could still be said about the original code

firstly, the /nc alias itself performs many more iterations than necessary: at least as many as the number of users in the channel - and potentially more. consider what happens if someone is both oped and voiced, or, as is common on various servers, both +q (~) and +a (&). one loop will switch their colour, and a later loop will change it back. again, potential flickering.

next, think about what will happen if there were a mode change such as '+o-o+h-h+v-v' (which is perfectly possible on most networks). 6 if statements satisfied, meaning 6 calls to /nc, and 6 times the flickering. try to keep 'elseif' in mind and always ask yourself if it should be used with a string of if statements.

however, even with elseifs, it doesn't handle mode changes such as '+mv nick'. a small change to the regular expression, but still doesn't do much to improve the overall approach. at the end of the day, it is important to realize that a method involving 'only perform necessary changes' should be preferred to 'clear all and reapply' wherever possible. imagine how computer games would perform if the programmer opted to wipe the canvas and re-draw everything from scratch at each frame!

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.