mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[USETUP]
- Cache the last data block and offset so we don't have to search from the start each time - This avoids needless swapping of cabinet data in and out of RAM - File copy in text-mode setup on 32 MB RAM is down from 8 minutes to 20 seconds (in my testing) svn path=/trunk/; revision=54632
This commit is contained in:
parent
80e8caa0b9
commit
13adb6230a
2 changed files with 17 additions and 4 deletions
|
@ -757,6 +757,12 @@ CabinetFindNext(PCAB_SEARCH Search)
|
|||
// FIXME: check for match against search criteria
|
||||
if (Search->File != Prev)
|
||||
{
|
||||
if (Prev == NULL || Search->File->FolderIndex != Prev->FolderIndex)
|
||||
{
|
||||
Search->CFData = NULL;
|
||||
Search->Offset = 0;
|
||||
}
|
||||
|
||||
/* don't match the file we started with */
|
||||
if (wcscmp(Search->Search, L"*") == 0)
|
||||
{
|
||||
|
@ -1011,10 +1017,12 @@ CabinetExtractFile(PCAB_SEARCH Search)
|
|||
ExtractHandler(Search->File, DestName);
|
||||
}
|
||||
|
||||
/* find the starting block of the file
|
||||
start with the first data block of the folder */
|
||||
CFData = (PCFDATA)(CabinetFolders[Search->File->FolderIndex].DataOffset + FileBuffer);
|
||||
CurrentOffset = 0;
|
||||
if (Search->CFData)
|
||||
CFData = Search->CFData;
|
||||
else
|
||||
CFData = (PCFDATA)(CabinetFolders[Search->File->FolderIndex].DataOffset + FileBuffer);
|
||||
|
||||
CurrentOffset = Search->Offset;
|
||||
while (CurrentOffset + CFData->UncompSize <= Search->File->FileOffset)
|
||||
{
|
||||
/* walk the data blocks until we reach
|
||||
|
@ -1023,6 +1031,9 @@ CabinetExtractFile(PCAB_SEARCH Search)
|
|||
CFData = (PCFDATA)((char *)(CFData + 1) + DataReserved + CFData->CompSize);
|
||||
}
|
||||
|
||||
Search->CFData = CFData;
|
||||
Search->Offset = CurrentOffset;
|
||||
|
||||
/* now decompress and discard any data in
|
||||
the block before the start of the file */
|
||||
|
||||
|
|
|
@ -108,6 +108,8 @@ typedef struct _CAB_SEARCH
|
|||
WCHAR Cabinet[MAX_PATH];
|
||||
USHORT Index;
|
||||
PCFFILE File; // Pointer to current CFFILE
|
||||
PCFDATA CFData;
|
||||
ULONG Offset;
|
||||
} CAB_SEARCH, *PCAB_SEARCH;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue