Index: /trunk/src/VBox/VMM/CFGM.cpp
===================================================================
--- /trunk/src/VBox/VMM/CFGM.cpp	(revision 23586)
+++ /trunk/src/VBox/VMM/CFGM.cpp	(revision 23587)
@@ -340,32 +340,4 @@
 
 /**
- * Compares two names.
- *
- * @returns Similar to memcpy.
- * @param   pszName1            The first name.
- * @param   cchName1            The length of the first name.
- * @param   pszName2            The second name.
- * @param   cchName2            The length of the second name.
- */
-DECLINLINE(int) cfgmR3CompareNames(const char *pszName1, size_t cchName1, const char *pszName2, size_t cchName2)
-{
-    int iDiff;
-    if (cchName1 <= cchName2)
-    {
-        iDiff = memcmp(pszName1, pszName2, cchName1);
-        if (!iDiff && cchName1 < cchName2)
-            iDiff = -1;
-    }
-    else
-    {
-        iDiff = memcmp(pszName1, pszName2, cchName2);
-        if (!iDiff)
-            iDiff = 1;
-    }
-    return iDiff;
-}
-
-
-/**
  * Validates that the child nodes are within a set of valid names.
  *
@@ -1035,48 +1007,50 @@
 static int cfgmR3ResolveNode(PCFGMNODE pNode, const char *pszPath, PCFGMNODE *ppChild)
 {
-    if (pNode)
-    {
-        PCFGMNODE pChild = NULL;
-        for (;;)
+    if (!pNode)
+        return VERR_CFGM_NO_PARENT;
+    PCFGMNODE pChild = NULL;
+    for (;;)
+    {
+        /* skip leading slashes. */
+        while (*pszPath == '/')
+            pszPath++;
+
+        /* End of path? */
+        if (!*pszPath)
         {
-            /* skip leading slashes. */
-            while (*pszPath == '/')
-                pszPath++;
-
-            /* End of path? */
-            if (!*pszPath)
+            if (!pChild)
+                return VERR_CFGM_INVALID_CHILD_PATH;
+            *ppChild = pChild;
+            return VINF_SUCCESS;
+        }
+
+        /* find end of component. */
+        const char *pszNext = strchr(pszPath, '/');
+        if (!pszNext)
+            pszNext = strchr(pszPath,  '\0');
+        RTUINT cchName = pszNext - pszPath;
+
+        /* search child list. */
+        pChild = pNode->pFirstChild;
+        for ( ; pChild; pChild = pChild->pNext)
+            if (pChild->cchName == cchName)
             {
-                if (!pChild)
-                    return VERR_CFGM_INVALID_CHILD_PATH;
-                *ppChild = pChild;
-                return VINF_SUCCESS;
+                int iDiff = memcmp(pszPath, pChild->szName, cchName);
+                if (iDiff <= 0)
+                {
+                    if (iDiff != 0)
+                        pChild = NULL;
+                    break;
+                }
             }
-
-            /* find end of component. */
-            const char *pszNext = strchr(pszPath, '/');
-            if (!pszNext)
-                pszNext = strchr(pszPath,  '\0');
-            RTUINT cchName = pszNext - pszPath;
-
-            /* search child list. */ /** @todo the list is ordered now, consider optimizing the search. */
-            pChild = pNode->pFirstChild;
-            for ( ; pChild; pChild = pChild->pNext)
-                if (    pChild->cchName == cchName
-                    &&  !memcmp(pszPath, pChild->szName, cchName) )
-                    break;
-
-            /* if not found, we're done. */
-            if (!pChild)
-                return VERR_CFGM_CHILD_NOT_FOUND;
-
-            /* next iteration */
-            pNode = pChild;
-            pszPath = pszNext;
-        }
-
-        /* won't get here */
-    }
-    else
-        return VERR_CFGM_NO_PARENT;
+        if (!pChild)
+            return VERR_CFGM_CHILD_NOT_FOUND;
+
+        /* next iteration */
+        pNode = pChild;
+        pszPath = pszNext;
+    }
+
+    /* won't get here */
 }
 
@@ -1092,27 +1066,27 @@
 static int cfgmR3ResolveLeaf(PCFGMNODE pNode, const char *pszName, PCFGMLEAF *ppLeaf)
 {
-    int rc;
-    if (pNode)
-    {
-        size_t      cchName = strlen(pszName);
-        PCFGMLEAF   pLeaf = pNode->pFirstLeaf;
-        while (pLeaf)
+    if (!pNode)
+        return VERR_CFGM_NO_PARENT;
+
+    size_t      cchName = strlen(pszName);
+    PCFGMLEAF   pLeaf   = pNode->pFirstLeaf;
+    while (pLeaf)
+    {
+        if (cchName == pLeaf->cchName)
         {
-            /** @todo the list is ordered now, consider optimizing the search. */
-            if (    cchName == pLeaf->cchName
-                && !memcmp(pszName, pLeaf->szName, cchName) )
+            int iDiff = memcmp(pszName, pLeaf->szName, cchName);
+            if (iDiff <= 0)
             {
+                if (iDiff != 0)
+                    break;
                 *ppLeaf = pLeaf;
                 return VINF_SUCCESS;
             }
-
-            /* next */
-            pLeaf = pLeaf->pNext;
         }
-        rc = VERR_CFGM_VALUE_NOT_FOUND;
-    }
-    else
-        rc = VERR_CFGM_NO_PARENT;
-    return rc;
+
+        /* next */
+        pLeaf = pLeaf->pNext;
+    }
+    return VERR_CFGM_VALUE_NOT_FOUND;
 }
 
@@ -1200,4 +1174,32 @@
     }
     return rc;
+}
+
+
+/**
+ * Compares two names.
+ *
+ * @returns Similar to memcpy.
+ * @param   pszName1            The first name.
+ * @param   cchName1            The length of the first name.
+ * @param   pszName2            The second name.
+ * @param   cchName2            The length of the second name.
+ */
+DECLINLINE(int) cfgmR3CompareNames(const char *pszName1, size_t cchName1, const char *pszName2, size_t cchName2)
+{
+    int iDiff;
+    if (cchName1 <= cchName2)
+    {
+        iDiff = memcmp(pszName1, pszName2, cchName1);
+        if (!iDiff && cchName1 < cchName2)
+            iDiff = -1;
+    }
+    else
+    {
+        iDiff = memcmp(pszName1, pszName2, cchName2);
+        if (!iDiff)
+            iDiff = 1;
+    }
+    return iDiff;
 }
 
@@ -1286,5 +1288,5 @@
             if (pNext)
             {
-                for (; pNext; pPrev = pNext, pNext = pNext->pNext)
+                for ( ; pNext; pPrev = pNext, pNext = pNext->pNext)
                 {
                     int iDiff = cfgmR3CompareNames(pszName, cchName, pNext->szName, pNext->cchName);
@@ -1428,5 +1430,5 @@
             if (pNext)
             {
-                for (; pNext; pPrev = pNext, pNext = pNext->pNext)
+                for ( ; pNext; pPrev = pNext, pNext = pNext->pNext)
                 {
                     int iDiff = cfgmR3CompareNames(pszName, cchName, pNext->szName, pNext->cchName);
