]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Micro-optimisation following helgrind secmap gc
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 11 May 2015 19:41:43 +0000 (19:41 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 11 May 2015 19:41:43 +0000 (19:41 +0000)
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

index 6a306f820142a15d50a0ba95f74f9eac0a5f64d0..e4a6ccec81c99937cbb3bcd11bd40eb6483d5e4b 100644 (file)
@@ -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;
 }