From: Vadim Zeitlin Date: Sun, 27 Apr 2003 15:17:46 +0000 (+0000) Subject: *really* fixed searching in sorted arrays X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/bb793b0cfb96d1bdfa26e668dfcdf5125f7e2fae *really* fixed searching in sorted arrays git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20359 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/dynarray.cpp b/src/common/dynarray.cpp index 573114aec0..2b185f156f 100644 --- a/src/common/dynarray.cpp +++ b/src/common/dynarray.cpp @@ -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 */ \