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

Alexandre Julliard julliard at winehq.org
Wed Nov 17 10:38:01 CST 2010


Module: wine
Branch: master
Commit: e883aeb3943ccf8b25b19ca582ea1d8b06561ed1
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e883aeb3943ccf8b25b19ca582ea1d8b06561ed1

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Mon Apr 19 16:55:49 2010 -0500

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;




More information about the wine-cvs mailing list