Author: jgardou
Date: Fri Apr 16 18:55:52 2010
New Revision: 46899
URL:
http://svn.reactos.org/svn/reactos?rev=46899&view=rev
Log:
[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...
Modified:
branches/reactos-yarotows/subsystems/win32/win32k/objects/gdiobj.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/gdiobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/objects/gdiobj.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/objects/gdiobj.c [iso-8859-1] Fri
Apr 16 18:55:52 2010
@@ -1625,37 +1625,39 @@
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)
- {
- unsorted = FALSE ;
- for(i=0; i<ulCount - 1; i++)
- {
- /* 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 ;
- }
- }
- }
- /* Then we lock them */
- for(i=0; i<ulCount; i++)
- {
- apObj[i]=GDIOBJ_LockObj(ahObj[i], GDI_OBJECT_TYPE_DONTCARE);
- }
+ UINT iFirst = 0, iSecond = 0, iThird = 0;
+ UINT i ;
+
+ /* First is greatest */
+ for(i=1; i<ulCount; i++)
+ {
+ if((ULONG_PTR)ahObj[i] >= (ULONG_PTR)ahObj[iFirst])
+ {
+ iSecond = iFirst ;
+ iFirst = i;
+ continue ;
+ }
+ if((ULONG_PTR)ahObj[i] >= (ULONG_PTR)ahObj[iSecond])
+ {
+ iSecond = i;
+ continue;
+ }
+ iThird = i;
+ }
+
+ /* We consider that at least two handles were passed */
+ apObj[iFirst] = GDIOBJ_LockObj(ahObj[iFirst], GDI_OBJECT_TYPE_DONTCARE);
+ apObj[iSecond] = GDIOBJ_LockObj(ahObj[iSecond], GDI_OBJECT_TYPE_DONTCARE);
+ if(ulCount == 3)
+ apObj[iThird] = GDIOBJ_LockObj(ahObj[iThird], GDI_OBJECT_TYPE_DONTCARE);
+
}