From 4ec4675b9e593a8875cbf31ddc7b647b78ed65ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Fri, 16 Apr 2010 16:55:52 +0000 Subject: [PATCH] [WIN32K] - There is currently no need to lock more than three objects at a time, this permits code simplification/speed - Keep the handles order in GDIOBJ_LockMultipleObjs Still unused... svn path=/branches/reactos-yarotows/; revision=46899 --- subsystems/win32/win32k/objects/gdiobj.c | 44 +++++++++++++----------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/subsystems/win32/win32k/objects/gdiobj.c b/subsystems/win32/win32k/objects/gdiobj.c index 70c131e31eb..a5c372364ac 100644 --- a/subsystems/win32/win32k/objects/gdiobj.c +++ b/subsystems/win32/win32k/objects/gdiobj.c @@ -1625,37 +1625,39 @@ GDI_MapHandleTable(PSECTION_OBJECT SectionObject, PEPROCESS Process) return MappedView; } -/* Locks multiple objects at a time */ +/* Locks up to 3 objects at a time */ VOID INTERNAL_CALL GDIOBJ_LockMultipleObjs(ULONG ulCount, IN HGDIOBJ* ahObj, OUT PGDIOBJ* apObj) { - UINT i; - HGDIOBJ hTmp ; - BOOL unsorted = TRUE; - /* We bubble-sort them */ - while(unsorted) + UINT iFirst = 0, iSecond = 0, iThird = 0; + UINT i ; + + /* First is greatest */ + for(i=1; i= (ULONG_PTR)ahObj[iFirst]) { - /* The greatest the first */ - if((ULONG_PTR)ahObj[i] < (ULONG_PTR)ahObj[i+1]) - { - hTmp = ahObj[i]; - ahObj[i]=ahObj[i+1]; - ahObj[i+1] = hTmp; - unsorted = TRUE ; - } + iSecond = iFirst ; + iFirst = i; + continue ; } + if((ULONG_PTR)ahObj[i] >= (ULONG_PTR)ahObj[iSecond]) + { + iSecond = i; + continue; + } + iThird = i; } - /* Then we lock them */ - for(i=0; i