From: Philippe Waroquiers Date: Mon, 11 May 2015 19:41:43 +0000 (+0000) Subject: Micro-optimisation following helgrind secmap gc X-Git-Tag: svn/VALGRIND_3_11_0~406 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=73266b0930f7549fafa610f3c03d551288f320c9;p=thirdparty%2Fvalgrind.git Micro-optimisation following helgrind secmap gc Checking the range in indexXA can be done with one comparison. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15211 --- diff --git a/coregrind/m_xarray.c b/coregrind/m_xarray.c index 6a306f8201..e4a6ccec81 100644 --- a/coregrind/m_xarray.c +++ b/coregrind/m_xarray.c @@ -127,9 +127,10 @@ void VG_(setCmpFnXA) ( XArray* xa, XACmpFn_t compar ) inline void* VG_(indexXA) ( const XArray* xa, Word n ) { - vg_assert(xa); - vg_assert(n >= 0); - vg_assert(n < xa->usedsizeE); + // vg_assert(xa); + // vg_assert(n >= 0); If n negative, the UWord conversion will make + // it bigger than usedsizeE. + vg_assert((UWord)n < xa->usedsizeE); return ((char*)xa->arr) + n * xa->elemSzB; }