diff options
author | sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2011-03-07 19:13:33 +0000 |
---|---|---|
committer | sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2011-03-07 19:13:33 +0000 |
commit | 0937c0fbd049431ae704d08d1e21c3090c392a91 (patch) | |
tree | 26a00ce2dc20d3b405b5118db64d0fc808e418c8 /helgrind | |
parent | baccf60933e207ac475a9345d615289a5f493972 (diff) |
Replace the structural equality function for WordVecs with a more
efficient one. n-i-bz.
(Philippe Waroquiers, philippe.waroquiers@skynet.be).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11609 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'helgrind')
-rw-r--r-- | helgrind/hg_wordset.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/helgrind/hg_wordset.c b/helgrind/hg_wordset.c index 330c2e66..a7cb8147 100644 --- a/helgrind/hg_wordset.c +++ b/helgrind/hg_wordset.c @@ -205,8 +205,17 @@ static Word cmp_WordVecs_for_FM ( UWord wv1W, UWord wv2W ) UWord i; WordVec* wv1 = (WordVec*)wv1W; WordVec* wv2 = (WordVec*)wv2W; - UWord common = wv1->size < wv2->size ? wv1->size : wv2->size; - for (i = 0; i < common; i++) { + + // WordVecs with smaller size are smaller. + if (wv1->size < wv2->size) { + return -1; + } + if (wv1->size > wv2->size) { + return 1; + } + + // Sizes are equal => order based on content. + for (i = 0; i < wv1->size; i++) { if (wv1->words[i] == wv2->words[i]) continue; if (wv1->words[i] < wv2->words[i]) @@ -215,19 +224,6 @@ static Word cmp_WordVecs_for_FM ( UWord wv1W, UWord wv2W ) return 1; tl_assert(0); } - /* Ok, the common sections are identical. So now consider the - tails. Both sets are considered to finish in an implied - sequence of -infinity. */ - if (wv1->size < wv2->size) { - tl_assert(common == wv1->size); - return -1; /* impliedly, wv1 contains some -infinitys in places - where wv2 doesn't. */ - } - if (wv1->size > wv2->size) { - tl_assert(common == wv2->size); - return 1; - } - tl_assert(common == wv1->size); return 0; /* identical */ } |