As proposed by CiccioBastardo here is a separate thread for the valid codes which are "ready-to-use" in your mod.
Please post only verified code here and use the discussion thread first to avoid confusion.
Use one post/reply for one optimization (where possible) to keep it clean.
Also, if you have a comment, either use the discussion thread or address to the modder who wrote the code.
Any post which violates the rules will be reported to the moderators.
Thx and happy posting,
WiZ
Page 1 of 1
Optimizations (final Codes) Why waste those precious cycles?
#1
Posted 08 January 2007 - 11:43 AM
#2
Posted 08 January 2007 - 11:49 AM
Files changed: UploadClient.cpp
eMule Version: 0.47c and pretty much all older versions
Optimization: small-medium
Changes:
Original code in UploadClient.cpp:
Optimized code in UploadClient.cpp:
eMule Version: 0.47c and pretty much all older versions
Optimization: small-medium
Changes:
Original code in UploadClient.cpp:
// check extension to decide whether to compress or not CString ext = srcfile->GetFileName(); ext.MakeLower(); int pos = ext.ReverseFind(_T('.')); if (pos>-1) ext = ext.Mid(pos); bool compFlag = (ext!=_T(".zip") && ext!=_T(".cbz") && ext!=_T(".rar") && ext!=_T(".cbr") && ext!=_T(".ace") && ext!=_T(".ogm")); if (ext==_T(".avi") && thePrefs.GetDontCompressAvi()) compFlag=false; if (!IsUploadingToPeerCache() && m_byDataCompVer == 1 && compFlag) CreatePackedPackets(filedata,togo,currentblock,bFromPF); else CreateStandartPackets(filedata,togo,currentblock,bFromPF);
Optimized code in UploadClient.cpp:
//>>> WiZaRd::Optimization bool compFlag = false; if (!IsUploadingToPeerCache() && m_byDataCompVer == 1) { //<<< WiZaRd::Optimization // check extension to decide whether to compress or not CString ext = srcfile->GetFileName(); ext.MakeLower(); int pos = ext.ReverseFind(_T('.')); if (pos>-1) ext = ext.Mid(pos); //>>> WiZaRd::Optimization compFlag = (ext!=_T(".zip") && ext!=_T(".cbz") && ext!=_T(".rar") && ext!=_T(".cbr") && ext!=_T(".ace") && ext!=_T(".ogm")); // bool compFlag = (ext!=_T(".zip") && ext!=_T(".cbz") && ext!=_T(".rar") && ext!=_T(".cbr") && ext!=_T(".ace") && ext!=_T(".ogm")); //<<< WiZaRd::Optimization if (ext==_T(".avi") && thePrefs.GetDontCompressAvi()) compFlag=false; //>>> WiZaRd::Optimization } if (compFlag) // if (!IsUploadingToPeerCache() && m_byDataCompVer == 1 && compFlag) //<<< WiZaRd::Optimization CreatePackedPackets(filedata,togo,currentblock,bFromPF); else CreateStandartPackets(filedata,togo,currentblock,bFromPF);
This post has been edited by tHeWiZaRdOfDoS: 08 January 2007 - 11:51 AM
#3
Posted 08 January 2007 - 11:51 AM
Files changed: BaseClient.cpp
eMule Version: 0.47c and pretty much all older versions
Optimization: small
Changes:
Original code in BaseClient.cpp:
Optimized code in BaseClient.cpp:
eMule Version: 0.47c and pretty much all older versions
Optimization: small
Changes:
Original code in BaseClient.cpp:
bool CUpDownClient::TryToConnect(bool bIgnoreMaxCon, CRuntimeClass* pClassSocket) { if (theApp.listensocket->TooManySockets() && !bIgnoreMaxCon && !(socket && socket->IsConnected())) { if(Disconnected(_T("Too many connections"))) { delete this; return false; } return true; }
Optimized code in BaseClient.cpp:
bool CUpDownClient::TryToConnect(bool bIgnoreMaxCon, CRuntimeClass* pClassSocket) { //>>> WiZaRd::Optimization if (!bIgnoreMaxCon && !(socket && socket->IsConnected()) && theApp.listensocket->TooManySockets()) // if (theApp.listensocket->TooManySockets() && !bIgnoreMaxCon && !(socket && socket->IsConnected())) //<<< WiZaRd::Optimization { if(Disconnected(_T("Too many connections"))) { delete this; return false; } return true; }
#4
Posted 09 January 2007 - 08:20 PM
Files changed: IPFilterDlg.cpp
eMule Version: 0.47c
Discussion thread entry point
Here are a couple of tweaks for CIPFilterDlg
Below is the standard InitIPFilters()
Below is an optimized version of InitIPFilters()
Below is the standard OnLvnGetDispInfoIPFilter()
Below is the optimized version of OnLvnGetDispInfoIPFilter(). Note: pDispInfo->item.cchTextMax was returning a value of 260.
Thanks for reading.
eMule Version: 0.47c
Discussion thread entry point
Here are a couple of tweaks for CIPFilterDlg
Below is the standard InitIPFilters()
[color="#000000"]void CIPFilterDlg::InitIPFilters() { CWaitCursor curWait; m_uIPFilterItems = 0; free(m_ppIPFilterItems); m_ppIPFilterItems = NULL; [color="#0000FF"]const[/color] CIPFilterArray& ipfilter = theApp.ipfilter->GetIPFilter(); m_uIPFilterItems = ipfilter.GetCount(); m_ppIPFilterItems = (const SIPFilter**)malloc([color="#0000FF"]sizeof[/color](*m_ppIPFilterItems) * m_uIPFilterItems); m_ulFilteredIPs = 0; [color="#0000FF"]for[/color] (UINT i = 0; i < m_uIPFilterItems; i++) { [color="#0000FF"]const[/color] SIPFilter* pFilter = ipfilter[i]; m_ppIPFilterItems[i] = pFilter; m_ulFilteredIPs += pFilter->end - pFilter->start + 1; } SortIPFilterItems(); m_ipfilter.SetItemCount(m_uIPFilterItems); SetDlgItemText(IDC_TOTAL_IPFILTER, GetFormatedUInt(m_uIPFilterItems)); SetDlgItemText(IDC_TOTAL_IPS, GetFormatedUInt(m_ulFilteredIPs)); }[/color]
Below is an optimized version of InitIPFilters()
[color="#000000"]void CIPFilterDlg::InitIPFilters() { CWaitCursor curWait; m_uIPFilterItems = 0; m_ulFilteredIPs = 0; free(m_ppIPFilterItems); m_ppIPFilterItems = NULL; [color="#0000FF"]const[/color] CIPFilterArray& ipfilter = theApp.ipfilter->GetIPFilter(); m_uIPFilterItems = ipfilter.GetCount(); [color="#0000FF"]void[/color]* pSource = ([color="#0000FF"]void[/color]*)ipfilter.GetData(); size_t allocsize = [color="#0000FF"]sizeof[/color](*m_ppIPFilterItems) * m_uIPFilterItems; m_ppIPFilterItems= (const SIPFilter**) malloc(allocsize); [color="#008000"]//copy all the data at once[/color] memcpy(([color="#0000FF"]void[/color]*)m_ppIPFilterItems,pSource,allocsize); UINT i = 0; for ( ; i < m_uIPFilterItems; i++) { const SIPFilter* pFilter = ipfilter[i]; m_ulFilteredIPs += pFilter->end - pFilter->start;[color="#008000"]//+1[/color] } m_ulFilteredIPs += i;[color="#008000"]//one addition instead of i*additions[/color] SortIPFilterItems(); m_ipfilter.SetItemCount(m_uIPFilterItems); SetDlgItemText(IDC_TOTAL_IPFILTER, GetFormatedUInt(m_uIPFilterItems)); SetDlgItemText(IDC_TOTAL_IPS, GetFormatedUInt(m_ulFilteredIPs)); }[/color]
Below is the standard OnLvnGetDispInfoIPFilter()
[color="#000000"][color="#0000FF"]void[/color] CIPFilterDlg::OnLvnGetDispInfoIPFilter(NMHDR *pNMHDR, LRESULT *pResult) { NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR); if (pDispInfo->item.mask & LVIF_TEXT) [color="#008000"]// *have* to check that flag!![/color] { [color="#0000FF"]switch[/color] (pDispInfo->item.iSubItem) { [color="#0000FF"]case[/color] IPFILTER_COL_START: if (pDispInfo->item.cchTextMax > 0){ _tcsncpy(pDispInfo->item.pszText, ipstr(htonl(m_ppIPFilterItems[pDispInfo->item.iItem]->start)), pDispInfo->item.cchTextMax); pDispInfo->item.pszText[pDispInfo->item.cchTextMax - 1] = _T('\');[color="#FF0000"]<-should read Backslash Zero board wont allow it[/color] } [color="#0000FF"]break[/color]; [color="#0000FF"]case[/color] IPFILTER_COL_END: if (pDispInfo->item.cchTextMax > 0){ _tcsncpy(pDispInfo->item.pszText, ipstr(htonl(m_ppIPFilterItems[pDispInfo->item.iItem]->end)), pDispInfo->item.cchTextMax); pDispInfo->item.pszText[pDispInfo->item.cchTextMax - 1] = _T('\');[color="#FF0000"]<-should read Backslash Zero board wont allow it[/color] } [color="#0000FF"]break[/color]; [color="#0000FF"]case[/color] IPFILTER_COL_LEVEL: if (pDispInfo->item.cchTextMax > 0){ _tcsncpy(pDispInfo->item.pszText, _itot(m_ppIPFilterItems[pDispInfo->item.iItem]->level, pDispInfo->item.pszText, 10), pDispInfo->item.cchTextMax); pDispInfo->item.pszText[pDispInfo->item.cchTextMax - 1] = _T('\');[color="#FF0000"]<-should read Backslash Zero board wont allow it[/color] } [color="#0000FF"]break[/color]; [color="#0000FF"]case[/color] IPFILTER_COL_HITS: if (pDispInfo->item.cchTextMax > 0){ _tcsncpy(pDispInfo->item.pszText, _itot(m_ppIPFilterItems[pDispInfo->item.iItem]->hits, pDispInfo->item.pszText, 10), pDispInfo->item.cchTextMax); pDispInfo->item.pszText[pDispInfo->item.cchTextMax - 1] = _T('\');[color="#FF0000"]<-should read Backslash Zero board wont allow it[/color] } [color="#0000FF"]break[/color]; [color="#0000FF"]case[/color] IPFILTER_COL_DESC: if (pDispInfo->item.cchTextMax > 0){ USES_CONVERSION; _tcsncpy(pDispInfo->item.pszText, A2T(m_ppIPFilterItems[pDispInfo->item.iItem]->desc), pDispInfo->item.cchTextMax); pDispInfo->item.pszText[pDispInfo->item.cchTextMax - 1] = _T('\');[color="#FF0000"]<-should read Backslash Zero board wont allow it[/color] } [color="#0000FF"]break[/color]; } } *pResult = 0; }[/color]
Below is the optimized version of OnLvnGetDispInfoIPFilter(). Note: pDispInfo->item.cchTextMax was returning a value of 260.
[color="#000000"]void CIPFilterDlg::OnLvnGetDispInfoIPFilter(NMHDR *pNMHDR, LRESULT *pResult) { NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR); if (pDispInfo->item.mask & LVIF_TEXT) [color="#008000"]// *have* to check that flag!![/color] { switch (pDispInfo->item.iSubItem) { [color="#0000FF"]case[/color] IPFILTER_COL_START: if (pDispInfo->item.cchTextMax >= 16){ [b][color="#008000"]//saves _tcsncpy padding with NULL characters[/color][/b] _tcsncpy(pDispInfo->item.pszText, ipstr(htonl(m_ppIPFilterItems[pDispInfo->item.iItem]->start)), 15); pDispInfo->item.pszText[15] = _T('\');[color="#FF0000"]<-should read Backslash Zero board wont allow it[/color] } [color="#0000FF"]break[/color]; [color="#0000FF"]case[/color] IPFILTER_COL_END: if (pDispInfo->item.cchTextMax >= 16){ _tcsncpy(pDispInfo->item.pszText, ipstr(htonl(m_ppIPFilterItems[pDispInfo->item.iItem]->end)), 15); pDispInfo->item.pszText[15] = _T('\');[color="#FF0000"]<-should read Backslash Zero board wont allow it[/color] } [color="#0000FF"]break[/color]; [color="#0000FF"]case[/color] IPFILTER_COL_LEVEL: if (pDispInfo->item.cchTextMax >= 5){ _tcsncpy(pDispInfo->item.pszText, _itot(m_ppIPFilterItems[pDispInfo->item.iItem]->level, pDispInfo->item.pszText, 10), 5); pDispInfo->item.pszText[5] = _T('\');[color="#FF0000"]<-should read Backslash Zero board wont allow it[/color] } [color="#0000FF"]break[/color]; [color="#0000FF"]case[/color] IPFILTER_COL_HITS: if (pDispInfo->item.cchTextMax >= 5){ _tcsncpy(pDispInfo->item.pszText, _itot(m_ppIPFilterItems[pDispInfo->item.iItem]->hits, pDispInfo->item.pszText, 10), 5); pDispInfo->item.pszText[5] = _T('\');[color="#FF0000"]<-should read Backslash Zero board wont allow it[/color] } [color="#0000FF"]break[/color]; [color="#0000FF"]case[/color] IPFILTER_COL_DESC: if(pDispInfo->item.cchTextMax > 0) { int stringlength = m_ppIPFilterItems[pDispInfo->item.iItem]->desc.GetLength(); if(stringlength > pDispInfo->item.cchTextMax) stringlength = pDispInfo->item.cchTextMax; USES_CONVERSION; _tcsncpy(pDispInfo->item.pszText, A2T(m_ppIPFilterItems[pDispInfo->item.iItem]->desc), stringlength); pDispInfo->item.pszText[stringlength] = _T('\');[color="#FF0000"]<-should read Backslash Zero board wont allow it[/color] } [color="#0000FF"]break[/color]; } } *pResult = 0; } [/color]
Thanks for reading.
#5
Posted 09 January 2007 - 09:02 PM
Files changed: ClientUDPSocket.cpp and UDPSocket.cpp
eMule Version: 0.47c
Discussion thread entry point
I was doing some profiling... When I noted that in CClientUDPSocket::SendTo() ipstr() took what I believed to be an excessive execution time for what it did. So, I looked at the code,(see the current code below) ipstr() returns a CString object and for eMule that's CStringT. Now CString objects seem expensive to me anyway, but when I looked at int CAsyncSocket::SendTo(const void* lpBuf, int nBufLen, UINT nHostPort, LPCTSTR lpszHostAddress, int nFlags) I found the first thing it does to our newly created TChar CString is convert it to an ASCII string, it then takes that ASCII string and with inet_addr(lpszAscii); turns it back to the uint32 value we started with in dwIP!!
Finally it makes a call to SendTo(lpBuf, nBufLen, (SOCKADDR*)&sockAddr, sizeof(sockAddr), nFlags);
Note: The INADDR_NONE error returned by inet_addr() has the value 0xffffffff which equals 255.255.255.255, the limited broadcast address,(INADDR_BROADCAST). Therefore passing 255.255.255.255/INADDR_BROADCAST would result in an error being returned by int CAsyncSocket::SendTo(const void* lpBuf, int nBufLen, UINT nHostPort, LPCTSTR lpszHostAddress, int nFlags).
Original CClientUDPSocket::SendTo()
MFC CAsyncSocket::CAsyncSocket::SendTo(const void* lpBuf, int nBufLen, UINT nHostPort, LPCTSTR lpszHostAddress, int nFlags)
Below is my optimized version of CClientUDPSocket::SendTo()
The same optimize can be applied to CUDPSocket::SendTo()
The Optimized code is below
Thanks for reading!
eMule Version: 0.47c
Discussion thread entry point
I was doing some profiling... When I noted that in CClientUDPSocket::SendTo() ipstr() took what I believed to be an excessive execution time for what it did. So, I looked at the code,(see the current code below) ipstr() returns a CString object and for eMule that's CStringT. Now CString objects seem expensive to me anyway, but when I looked at int CAsyncSocket::SendTo(const void* lpBuf, int nBufLen, UINT nHostPort, LPCTSTR lpszHostAddress, int nFlags) I found the first thing it does to our newly created TChar CString is convert it to an ASCII string, it then takes that ASCII string and with inet_addr(lpszAscii); turns it back to the uint32 value we started with in dwIP!!
Finally it makes a call to SendTo(lpBuf, nBufLen, (SOCKADDR*)&sockAddr, sizeof(sockAddr), nFlags);
Note: The INADDR_NONE error returned by inet_addr() has the value 0xffffffff which equals 255.255.255.255, the limited broadcast address,(INADDR_BROADCAST). Therefore passing 255.255.255.255/INADDR_BROADCAST would result in an error being returned by int CAsyncSocket::SendTo(const void* lpBuf, int nBufLen, UINT nHostPort, LPCTSTR lpszHostAddress, int nFlags).
Original CClientUDPSocket::SendTo()
[color="#000000"][color="#0000FF"]int[/color] CClientUDPSocket::SendTo([color="#0000FF"]char[/color]* lpBuf,[color="#0000FF"]int [/color]nBufLen,uint32 dwIP, uint16 nPort){ [color="#008000"]// NOTE: *** This function is invoked from a *different* thread![/color] uint32 result = CAsyncSocket::SendTo(lpBuf,nBufLen,nPort,[b]ipstr(dwIP)[/b]); [color="#0000FF"]if[/color] (result == (uint32)SOCKET_ERROR){ uint32 error = GetLastError(); if (error == WSAEWOULDBLOCK){ m_bWouldBlock = [color="#0000FF"]true[/color]; [color="#0000FF"]return[/color] -1; } [color="#0000FF"]if[/color] (thePrefs.GetVerbose()) DebugLogError(_T("Error: Client UDP socket, failed to send data to %s:%u: %s"), ipstr(dwIP), nPort, GetErrorMessage(error, 1)); } [color="#0000FF"]return[/color] 0;[/color] }
MFC CAsyncSocket::CAsyncSocket::SendTo(const void* lpBuf, int nBufLen, UINT nHostPort, LPCTSTR lpszHostAddress, int nFlags)
[size=1][color="#000000"] [color="#008000"]// This is a part of the Microsoft Foundation Classes C++ library. // Copyright © Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // Microsoft Foundation Classes Reference and related // electronic documentation provided with the library. // See these sources for detailed information regarding the // Microsoft Foundation Classes product.[/color] [color="#0000FF"]int[/color] CAsyncSocket::SendTo([color="#0000FF"]const void[/color]* lpBuf, [color="#0000FF"]int[/color] nBufLen, UINT nHostPort, LPCTSTR lpszHostAddress, [color="#0000FF"]int[/color] nFlags) { USES_CONVERSION_EX; SOCKADDR_IN sockAddr; memset(&sockAddr,0,[color="#0000FF"]sizeof[/color](sockAddr)); LPSTR lpszAscii; [color="#0000FF"]if[/color] (lpszHostAddress != NULL) { lpszAscii = T2A_EX((LPTSTR)lpszHostAddress, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); [color="#0000FF"]if[/color] (lpszAscii == NULL) { [color="#008000"]// OUT OF MEMORY[/color] WSASetLastError(ERROR_NOT_ENOUGH_MEMORY); [color="#0000FF"]return[/color] FALSE; } } [color="#0000FF"]else[/color] { lpszAscii = NULL; } sockAddr.sin_family = AF_INET; [color="#0000FF"]if[/color] (lpszAscii == NULL) sockAddr.sin_addr.s_addr = htonl(INADDR_BROADCAST); [color="#0000FF"]else[/color] { sockAddr.sin_addr.s_addr = inet_addr(lpszAscii); [color="#0000FF"]if[/color] (sockAddr.sin_addr.s_addr == INADDR_NONE) { LPHOSTENT lphost; lphost = gethostbyname(lpszAscii); [color="#0000FF"]if[/color] (lphost != NULL) sockAddr.sin_addr.s_addr = ((LPIN_ADDR)lphost->h_addr)->s_addr; [color="#0000FF"]else[/color] { WSASetLastError(WSAEINVAL); [color="#0000FF"]return[/color] SOCKET_ERROR; } } } sockAddr.sin_port = htons((u_short)nHostPort); [b][color="#0000FF"]return[/color] SendTo(lpBuf, nBufLen, (SOCKADDR*)&sockAddr, [color="#0000FF"]sizeof[/color](sockAddr), nFlags);[/b] }[/color][/size]
Below is my optimized version of CClientUDPSocket::SendTo()
[color="#000000"][color="#0000FF"]int[/color] CClientUDPSocket::SendTo([color="#0000FF"]char[/color]* lpBuf,int nBufLen,uint32 dwIP, uint16 nPort){ [color="#008000"]// NOTE: *** This function is invoked from a *different* thread! [b] //TK4 MOD 2.0c - Save converting dwIP from uint32 to a CStringT to ASCII then back to uint32[/color] [color="#0000FF"]if[/color](dwIP == INADDR_BROADCAST) { WSASetLastError(WSAEINVAL); [color="#0000FF"]if[/color] (thePrefs.GetVerbose()) DebugLogError(_T("Error: Client UDP socket, failed to send data to %s:%u: %s"), ipstr(dwIP), nPort, GetErrorMessage(WSAEINVAL, 1)); [color="#0000FF"]return[/color] 0; } SOCKADDR_IN sockAddr; memset(&sockAddr, 0,sizeof(sockAddr)); sockAddr.sin_family = AF_INET; sockAddr.sin_addr.s_addr = dwIP; sockAddr.sin_port = htons((u_short)nPort); uint32 result = CAsyncSocket::SendTo(lpBuf, nBufLen, (SOCKADDR*)&sockAddr, [color="#0000FF"]sizeof[/color](sockAddr), 0);[/b] [color="#008000"]// uint32 result = CAsyncSocket::SendTo(lpBuf,nBufLen,nPort,ipstr(dwIP)); [/color] [color="#0000FF"]if[/color] (result == (uint32)SOCKET_ERROR){ uint32 error = GetLastError(); [color="#0000FF"]if[/color] (error == WSAEWOULDBLOCK){ m_bWouldBlock = [color="#0000FF"]true[/color]; [color="#0000FF"]return[/color] -1; } [color="#0000FF"]if[/color] (thePrefs.GetVerbose()) DebugLogError(_T("Error: Client UDP socket, failed to send data to %s:%u: %s"), ipstr(dwIP), nPort, GetErrorMessage(error, 1)); } [color="#0000FF"]return[/color] 0; }[/color]
The same optimize can be applied to CUDPSocket::SendTo()
The Optimized code is below
[color="#000000"][color="#0000FF"]int[/color] CUDPSocket::SendTo(BYTE* lpBuf, [color="#0000FF"]int[/color] nBufLen, uint32 dwIP, uint16 nPort) { [color="#008000"]// NOTE: *** This function is invoked from a *different* thread! [b]//TK4 MOD 2.0c - Save converting dwIP from uint32 to a CStringT to ASCII then back to uint32[/color] [color="#0000FF"]if[/color](dwIP == INADDR_BROADCAST) { WSASetLastError(WSAEINVAL); [color="#0000FF"]if[/color] (thePrefs.GetVerbose()) DebugLogError(_T("Error: Client UDP socket, failed to send data to %s:%u: %s"), ipstr(dwIP), nPort, GetErrorMessage(WSAEINVAL, 1)); [color="#0000FF"]return[/color] 0; } SOCKADDR_IN sockAddr; memset(&sockAddr, 0,[color="#0000FF"]sizeof[/color](sockAddr)); sockAddr.sin_family = AF_INET; sockAddr.sin_addr.s_addr = dwIP; sockAddr.sin_port = htons((u_short)nPort); [color="#0000FF"]int[/color] iResult = CAsyncSocket::SendTo(lpBuf, nBufLen, (SOCKADDR*)&sockAddr, sizeof(sockAddr), 0);[/b] [color="#008000"] //int iResult = CAsyncSocket::SendTo(lpBuf, nBufLen, nPort, ipstr(dwIP));[/color] [color="#0000FF"]if[/color] (iResult == SOCKET_ERROR) { DWORD dwError = GetLastError(); [color="#0000FF"]if[/color] (dwError == WSAEWOULDBLOCK) { m_bWouldBlock = [color="#0000FF"]true[/color]; [color="#0000FF"]return[/color] -1; [color="#008000"]// blocked[/color] } [color="#0000FF"]else[/color]{ [color="#0000FF"]if[/color] (thePrefs.GetVerbose()) theApp.QueueDebugLogLine([color="#0000FF"]false[/color], _T("Error: Server UDP socket: Failed to send packet to %s:%u - %s"), ipstr(dwIP), nPort, GetErrorMessage(dwError, 1)); [color="#0000FF"]return[/color] 0; [color="#008000"]// error[/color] } } [color="#0000FF"]return[/color] 1; [color="#008000"]// success[/color] }[/color]
Thanks for reading!
#6
Posted 10 April 2007 - 11:57 AM
When sharing many (MANY) files this single line saves a lot of CPU when connecting or disconnecting to a server.
Add one condition:
Add one condition:
Quote
void CSharedFileList::ClearED2KPublishInfo()
{
CKnownFile* cur_file;
CCKey bufKey;
m_lastPublishED2KFlag = true;
for (POSITION pos = m_Files_map.GetStartPosition();pos != 0;)
{
m_Files_map.GetNextAssoc(pos,bufKey,cur_file);
if (cur_file->GetPublishedED2K()) // MORPH optimization for large shared filelist, only reset if published.
cur_file->SetPublishedED2K(false);
}
}
{
CKnownFile* cur_file;
CCKey bufKey;
m_lastPublishED2KFlag = true;
for (POSITION pos = m_Files_map.GetStartPosition();pos != 0;)
{
m_Files_map.GetNextAssoc(pos,bufKey,cur_file);
if (cur_file->GetPublishedED2K()) // MORPH optimization for large shared filelist, only reset if published.
cur_file->SetPublishedED2K(false);
}
}
Download the MorphXT emule mod here: eMule Morph mod
Trouble connecting to a server? Use kad and /or refresh your server list
Strange search results? Check for fake servers! Or download morph, enable obfuscated server required, and far less fake server seen.
Looking for morphXT translators. If you want to translate the morph strings please come here (you only need to be able to write, no coding required. ) Covered now: cn,pt(br),it,es_t,fr.,pl Update needed:de,nl
-Morph FAQ [English wiki]--Het grote emule topic deel 13 [Nederlands]
if you want to send a message i will tell you to open op a topic in the forum. Other forum lurkers might be helped as well.
Trouble connecting to a server? Use kad and /or refresh your server list
Strange search results? Check for fake servers! Or download morph, enable obfuscated server required, and far less fake server seen.
Looking for morphXT translators. If you want to translate the morph strings please come here (you only need to be able to write, no coding required. ) Covered now: cn,pt(br),it,es_t,fr.,pl Update needed:de,nl
-Morph FAQ [English wiki]--Het grote emule topic deel 13 [Nederlands]
if you want to send a message i will tell you to open op a topic in the forum. Other forum lurkers might be helped as well.
Page 1 of 1