View Single Post
  #11  
Old 11-21-2003, 09:21 AM
Merth
Dragon
 
Join Date: May 2003
Location: Seattle, WA
Posts: 609
Default

I've been going through the networking code and making small linked list optimizations. It won't affect the bottom line much, but you may want to do the same for the code you are dealing with.

Old code:
Code:
LinkedListIterator<EQNetworkConnection*> iterator(*list);
iterator.Reset();
while (iterator.MoreElements()) {
	if (iterator.GetData()->IsFree() && (!iterator.GetData()->CheckNetActive())) {
		iterator.RemoveCurrent();
	}
	else {
		iterator.GetData()->Process(sock);
		iterator.Advance();
	}
}
Optimized code:
Code:
LinkedListIterator<EQNetworkConnection*> iterator(*list);
iterator.Reset();
while (iterator.MoreElements()) {
	EQNetworkConnection* eqnc_data = iterator.GetData();
	if (eqnc_data->IsFree() && (!eqnc_data->CheckNetActive())) {
		iterator.RemoveCurrent();
	}
	else {
		eqnc_data->Process(sock);
		iterator.Advance();
	}
}
*EDIT* I also noticed this sort of behavior with the CastToXXXX() type functions. You may also want to cache that call, as it is sometimes invoked repeatedly, unnecessarily.
Reply With Quote