Commit e883aeb3 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

ole32: Cache the contents of one extended big block depot block.

parent 14a77db4
......@@ -2760,6 +2760,7 @@ static HRESULT StorageImpl_Construct(
* There is no block depot cached yet.
*/
This->indexBlockDepotCached = 0xFFFFFFFF;
This->indexExtBlockDepotCached = 0xFFFFFFFF;
/*
* Start searching for free blocks with block 0.
......@@ -3134,17 +3135,32 @@ static ULONG Storage32Impl_GetExtDepotBlock(StorageImpl* This, ULONG depotIndex)
ULONG extBlockOffset = numExtBlocks % depotBlocksPerExtBlock;
ULONG blockIndex = BLOCK_UNUSED;
ULONG extBlockIndex;
BYTE depotBuffer[MAX_BIG_BLOCK_SIZE];
int index, num_blocks;
assert(depotIndex >= COUNT_BBDEPOTINHEADER);
if (extBlockCount >= This->extBigBlockDepotCount)
return BLOCK_UNUSED;
if (This->indexExtBlockDepotCached != extBlockCount)
{
extBlockIndex = This->extBigBlockDepotLocations[extBlockCount];
if (extBlockIndex != BLOCK_UNUSED)
StorageImpl_ReadDWordFromBigBlock(This, extBlockIndex,
extBlockOffset * sizeof(ULONG), &blockIndex);
StorageImpl_ReadBigBlock(This, extBlockIndex, depotBuffer);
num_blocks = This->bigBlockSize / 4;
for (index = 0; index < num_blocks; index++)
{
StorageUtl_ReadDWord(depotBuffer, index*sizeof(ULONG), &blockIndex);
This->extBlockDepotCached[index] = blockIndex;
}
This->indexExtBlockDepotCached = extBlockCount;
}
blockIndex = This->extBlockDepotCached[extBlockOffset];
return blockIndex;
}
......@@ -3176,6 +3192,11 @@ static void Storage32Impl_SetExtDepotBlock(StorageImpl* This, ULONG depotIndex,
extBlockOffset * sizeof(ULONG),
blockIndex);
}
if (This->indexExtBlockDepotCached == extBlockCount)
{
This->extBlockDepotCached[extBlockOffset] = blockIndex;
}
}
/******************************************************************************
......
......@@ -358,6 +358,9 @@ struct StorageImpl
ULONG extBigBlockDepotCount;
ULONG bigBlockDepotStart[COUNT_BBDEPOTINHEADER];
ULONG extBlockDepotCached[MAX_BIG_BLOCK_SIZE / 4];
ULONG indexExtBlockDepotCached;
ULONG blockDepotCached[MAX_BIG_BLOCK_SIZE / 4];
ULONG indexBlockDepotCached;
ULONG prevFreeBlock;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment