]> git.saurik.com Git - wxWidgets.git/commitdiff
*really* fixed searching in sorted arrays
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 27 Apr 2003 15:17:46 +0000 (15:17 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 27 Apr 2003 15:17:46 +0000 (15:17 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20359 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/dynarray.cpp

index 573114aec0017cd9175d83f1a797e0cbef3a870e..2b185f156f4f91f3ff4230645073df0c4f199e37 100644 (file)
@@ -283,10 +283,10 @@ int name::Index(T lItem, CMPFUNC fnCompare) const                           \
 {                                                                           \
     size_t n = IndexForInsert(lItem, fnCompare);                            \
                                                                             \
-    return n < m_nCount &&                                                  \
+    return (n >= m_nCount ||                                                \
            (*fnCompare)((const void *)(long)lItem,                          \
-                        ((const void *)(long)m_pItems[n])) ? wxNOT_FOUND    \
-                                                           : (int)n;        \
+                        ((const void *)(long)m_pItems[n]))) ? wxNOT_FOUND   \
+                                                            : (int)n;       \
 }                                                                           \
                                                                             \
 /* add item at the end */                                                   \