A
Alhexx
Guest
I need your help once again.
As you might have noticed in the scrollbar topic, I'm working on an archive (de)compressor called Kaddy. The tool works pretty well, but I have one problem that makes my head ache (or maybe it's the maths exam I wrote today... :erm: )
Well, okay. When I load an archive, let's say battle.lgp, Kaddy opens the file and creates a file list. This goes very fast.
However, I use a CListView class (the "same" as CListCtrl) to display this file list. Here's a screenshot
As you might know, battle.lgp has over 11K files...
Now the problem is:
It takes almost 2 mintues (!) until Kaddy has added all items to the CListCtrl view class!
Here's the code I currently use:
Code: [Select]
The part where most of the time is spend is the last for-loop.
Now my question is:
Is there any possibility to modify that code to increase the speed?
I'm not sure, but I suppose that the CString.Format method need that much time...
I cannot allow Kaddy to need 2 minutes for rendering a 10K file list... :-?
Any ideas?
- Alhexx
As you might have noticed in the scrollbar topic, I'm working on an archive (de)compressor called Kaddy. The tool works pretty well, but I have one problem that makes my head ache (or maybe it's the maths exam I wrote today... :erm: )
Well, okay. When I load an archive, let's say battle.lgp, Kaddy opens the file and creates a file list. This goes very fast.
However, I use a CListView class (the "same" as CListCtrl) to display this file list. Here's a screenshot
As you might know, battle.lgp has over 11K files...
Now the problem is:
It takes almost 2 mintues (!) until Kaddy has added all items to the CListCtrl view class!
Here's the code I currently use:
Code: [Select]
Code:
void CKaddyView::RenderNode(){ CListCtrl& lst = GetListCtrl(); // Clear current list lst.DeleteAllItems(); if(m_pcurDir == NULL) return; unsigned long ulIndex = 0; // Is this not the root dir? if(m_pcurDir->pParent != NULL) { lst.InsertItem(LVS_INS, ulIndex, "..", 0, 0, 0, ulIndex); lst.SetItemText(ulIndex++, 3, "p"); } CString strId; // Do we have sub-dirs? for(unsigned long i = 0; i < m_pcurDir->ulNumSubDirs; i++) { strId.Format("d%i", i); lst.InsertItem(LVS_INS, ulIndex, &m_pcurDir->pNames[m_pcurDir->pSubDirs[i].ulNameOffset], 0, 0, 0, ulIndex); lst.SetItemText(ulIndex++, 3, strId); } CString Buf; // Do we have files? for(unsigned long i = 0; i < m_pcurDir->ulNumFiles; i++) { strId.Format("f%i", i); lst.InsertItem(LVS_INS, ulIndex, &m_pcurDir->pNames[m_pcurDir->pFiles[i].ulNameOffset], 0, 0, 2, ulIndex); Buf.Format("%i", m_pcurDir->pFiles[i].ulFileSize); lst.SetItemText(ulIndex, 1, Buf); Buf.Format("%i", m_pcurDir->pFiles[i].ulCompressedSize); lst.SetItemText(ulIndex, 2, Buf); lst.SetItemText(ulIndex++, 3, strId); } // That's it UpdateWindow();}
The part where most of the time is spend is the last for-loop.
Now my question is:
Is there any possibility to modify that code to increase the speed?
I'm not sure, but I suppose that the CString.Format method need that much time...
I cannot allow Kaddy to need 2 minutes for rendering a 10K file list... :-?
Any ideas?
- Alhexx