From 96f7e506fc8bb41c2c4b1971d5041e865bce94b4 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Mon, 19 Apr 2010 16:55:49 -0500 Subject: [PATCH] ole32: Cache the contents of one extended big block depot block. --- dlls/ole32/storage32.c | 29 +++++++++++++++++++++++++---- dlls/ole32/storage32.h | 3 +++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index 311f2ae..b58e445 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -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; - extBlockIndex = This->extBigBlockDepotLocations[extBlockCount]; + 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; + } } /****************************************************************************** diff --git a/dlls/ole32/storage32.h b/dlls/ole32/storage32.h index 72a5fe7..0f8b3b4 100644 --- a/dlls/ole32/storage32.h +++ b/dlls/ole32/storage32.h @@ -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; -- 1.7.1