[ros-diffs] [weiden] 30518: Optimize GetAncestor for the most common case GA_PARENT (for now)

weiden at svn.reactos.org weiden at svn.reactos.org
Sat Nov 17 07:22:40 CET 2007


Author: weiden
Date: Sat Nov 17 09:22:39 2007
New Revision: 30518

URL: http://svn.reactos.org/svn/reactos?rev=30518&view=rev
Log:
Optimize GetAncestor for the most common case GA_PARENT (for now)

Modified:
    trunk/reactos/dll/win32/user32/windows/window.c

Modified: trunk/reactos/dll/win32/user32/windows/window.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/window.c?rev=30518&r1=30517&r2=30518&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/window.c (original)
+++ trunk/reactos/dll/win32/user32/windows/window.c Sat Nov 17 09:22:39 2007
@@ -842,7 +842,42 @@
 HWND STDCALL
 GetAncestor(HWND hwnd, UINT gaFlags)
 {
-  return(NtUserGetAncestor(hwnd, gaFlags));
+    HWND Ret = NULL;
+    PWINDOW Ancestor, Wnd;
+    
+    Wnd = ValidateHwnd(hwnd);
+    if (!Wnd)
+        return NULL;
+
+    _SEH_TRY
+    {
+        Ancestor = NULL;
+        switch (gaFlags)
+        {
+            case GA_PARENT:
+                if (Wnd->Parent != NULL)
+                    Ancestor = DesktopPtrToUser(Wnd->Parent);
+                break;
+
+            default:
+                /* FIXME: Call win32k for now */
+                Wnd = NULL;
+                break;
+        }
+
+        if (Ancestor != NULL)
+            Ret = UserHMGetHandle(Ancestor);
+    }
+    _SEH_HANDLE
+    {
+        /* Do nothing */
+    }
+    _SEH_END;
+
+    if (!Wnd) /* Fall back */
+        Ret = NtUserGetAncestor(hwnd, gaFlags);
+
+    return Ret;
 }
 
 




More information about the Ros-diffs mailing list