From 428e6983d11bdd783d162c20e28890fe58859b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Mon, 24 Mar 2003 22:50:17 +0000 Subject: [PATCH] Speed up search for free handle somewhat svn path=/trunk/; revision=4426 --- reactos/subsys/win32k/eng/handle.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reactos/subsys/win32k/eng/handle.c b/reactos/subsys/win32k/eng/handle.c index 3e6ad67a951..65716481df4 100644 --- a/reactos/subsys/win32k/eng/handle.c +++ b/reactos/subsys/win32k/eng/handle.c @@ -14,6 +14,7 @@ #define NDEBUG #include +static int LastHandle = MAX_GDI_HANDLES; ULONG CreateGDIHandle(ULONG InternalSize, ULONG UserSize) { @@ -31,11 +32,13 @@ ULONG CreateGDIHandle(ULONG InternalSize, ULONG UserSize) pObj->InternalSize = InternalSize; pObj->UserSize = UserSize; - for( i=1; i < MAX_GDI_HANDLES; i++ ){ + for( i = (MAX_GDI_HANDLES - 1 <= LastHandle ? 1 : LastHandle + 1); i != LastHandle; + i = (MAX_GDI_HANDLES - 1 <= i ? 1 : i + 1) ){ if( GDIHandles[ i ].pEngObj == NULL ){ pObj->hObj = i; GDIHandles[ i ].pEngObj = pObj; DPRINT("CreateGDIHandle: obj: %x, handle: %d, usersize: %d\n", pObj, i, UserSize ); + LastHandle = i; return i; } }