From 73266b0930f7549fafa610f3c03d551288f320c9 Mon Sep 17 00:00:00 2001 From: Philippe Waroquiers Date: Mon, 11 May 2015 19:41:43 +0000 Subject: [PATCH] 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 --- coregrind/m_xarray.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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; } -- 2.47.3