[PATCH v2 3/3] comdlg32: Optimize locking in filedlg.
Lauri Kenttä
lauri.kentta at gmail.com
Sat Jun 25 05:49:13 CDT 2016
Related to bug 26803.
Previously FILEDLG95_FILENAME_FillFromSelection would repeatedly call
IDataObject_GetData, GlobalLock etc. This patch avoids some of these
unnecessary calls by moving them outside the loop.
This gives 20% speed-up for selecting 253 files with shift-click.
Signed-off-by: Lauri Kenttä <lauri.kentta at gmail.com>
---
dlls/comdlg32/filedlg.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c
index 261095f..e84057c 100644
--- a/dlls/comdlg32/filedlg.c
+++ b/dlls/comdlg32/filedlg.c
@@ -225,6 +225,8 @@ LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
static LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPWSTR lpcstrFileName);
static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl);
static UINT GetNumSelected( IDataObject *doSelected );
+static void COMCTL32_ReleaseStgMedium(STGMEDIUM medium);
+static FORMATETC* GetFormatEtc(void);
/* Shell memory allocation */
static void *MemAlloc(UINT size);
@@ -3630,12 +3632,19 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
LPITEMIDLIST pidl;
UINT nFiles = 0, nFileToOpen, nFileSelected, nAllFilesLength = 0, nThisFileLength, nAllFilesMaxLength;
LPWSTR lpstrAllFiles, lpstrTmp;
+ STGMEDIUM medium;
+ LPIDA cida;
TRACE("\n");
fodInfos = GetPropA(hwnd, FileOpenDlgInfosStr);
+ if (FAILED(IDataObject_GetData(fodInfos->Shell.FOIDataObject, GetFormatEtc(), &medium)))
+ return;
+
+ cida = GlobalLock(medium.u.hGlobal);
+
/* Count how many files we have */
- nFileSelected = GetNumSelected(fodInfos->Shell.FOIDataObject);
+ nFileSelected = cida->cidl;
/* Allocate a buffer */
nAllFilesMaxLength = MAX_PATH + 3;
@@ -3646,7 +3655,7 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
/* Loop through the selection, handle only files (not folders) */
for (nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++)
{
- pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, nFileToOpen + 1);
+ pidl = (LPITEMIDLIST)((LPBYTE)cida + cida->aoffset[nFileToOpen + 1]);
if (pidl)
{
if (!IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl))
@@ -3667,7 +3676,6 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
lpstrAllFiles[nAllFilesLength++] = '"';
lpstrAllFiles[nAllFilesLength++] = ' ';
}
- COMDLG32_SHFree(pidl);
}
}
@@ -3688,6 +3696,7 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
ret:
HeapFree(GetProcessHeap(), 0, lpstrAllFiles);
+ COMCTL32_ReleaseStgMedium(medium);
}
--
2.9.0
More information about the wine-patches
mailing list