Guess it does not contains 'Contains'
-
Recently reported a performance hit, hours later noticed this piece of code that caused it, further more the eventhandler was hooked to the event more than once! :mad:
bool canExecute = false; ArrayList targetObjects = previousObject.TargetObjects; for (int i = 0; i < targetObjects.Count; i++) { if (targetObjects\[i\].Equals(this)) { canExecute = true; } } if (canExecute) { // Processing on event data. }
At least there should be a break point when it is met!! :laugh:
-
Recently reported a performance hit, hours later noticed this piece of code that caused it, further more the eventhandler was hooked to the event more than once! :mad:
bool canExecute = false; ArrayList targetObjects = previousObject.TargetObjects; for (int i = 0; i < targetObjects.Count; i++) { if (targetObjects\[i\].Equals(this)) { canExecute = true; } } if (canExecute) { // Processing on event data. }
At least there should be a break point when it is met!! :laugh:
vallarasus wrote:
At least there should be a break point when it is met!!
So true. I've used something similar, but also kept the last 'hit' as it was more likely to be the next one. Another version I've see is a linked list and whenever a target is hit, it's moved to the top of the list.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
-
vallarasus wrote:
At least there should be a break point when it is met!!
So true. I've used something similar, but also kept the last 'hit' as it was more likely to be the next one. Another version I've see is a linked list and whenever a target is hit, it's moved to the top of the list.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
That's a joke :laugh: However in this case there should be no iterator!!