|
From: <sv...@va...> - 2005-09-20 13:31:46
|
Author: sewardj
Date: 2005-09-20 14:31:44 +0100 (Tue, 20 Sep 2005)
New Revision: 4702
Log:
Speed up a common-case use of is_valid_for_client.
Modified:
branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c
Modified: branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-20 13:06:3=
2 UTC (rev 4701)
+++ branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-20 13:31:4=
4 UTC (rev 4702)
@@ -1032,7 +1032,19 @@
needX =3D toBool(prot & VKI_PROT_EXEC);
=20
iLo =3D find_nsegment_idx(start);
- iHi =3D find_nsegment_idx(start + len - 1);
+ aspacem_assert(start >=3D nsegments[iLo].start);
+
+ if (start+len-1 <=3D nsegments[iLo].end) {
+ /* This is a speedup hack which avoids calling find_nsegment_idx
+ a second time when possible. It is always correct to just
+ use the "else" clause below, but is_valid_for_client is
+ called a lot by the leak checker, so avoiding pointless calls
+ to find_nsegment_idx, which can be expensive, is helpful. */
+ iHi =3D iLo;
+ } else {
+ iHi =3D find_nsegment_idx(start + len - 1);
+ }
+
for (i =3D iLo; i <=3D iHi; i++) {
if ( (nsegments[i].kind =3D=3D SkFileC=20
|| nsegments[i].kind =3D=3D SkAnonC
|