From 67127b838d935876a879b1ced82f45de8e47621f Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 30 May 2013 09:46:13 -0700 Subject: New DSD detection code. --- src/misc/vec/vecHsh.h | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/misc/vec/vecHsh.h') diff --git a/src/misc/vec/vecHsh.h b/src/misc/vec/vecHsh.h index 0d16c012..2d15fce7 100644 --- a/src/misc/vec/vecHsh.h +++ b/src/misc/vec/vecHsh.h @@ -137,10 +137,18 @@ static inline int Hsh_IntManHash( unsigned * pData, int nSize, int nTableSize ) Key += pDataC[c] * s_Primes[c % 7]; return (int)(Key % nTableSize); } -static inline int Hsh_IntManAdd( Hsh_IntMan_t * p, int iData ) +static inline int * Hsh_IntManLookup( Hsh_IntMan_t * p, unsigned * pData ) { Hsh_IntObj_t * pObj; - unsigned * pData = Hsh_IntData( p, iData ); + int * pPlace = Vec_IntEntryP( p->vTable, Hsh_IntManHash(pData, p->nSize, Vec_IntSize(p->vTable)) ); + for ( ; (pObj = Hsh_IntObj(p, *pPlace)); pPlace = &pObj->iNext ) + if ( !memcmp( pData, Hsh_IntData(p, pObj->iData), sizeof(int) * p->nSize ) ) + return pPlace; + assert( *pPlace == -1 ); + return pPlace; +} +static inline int Hsh_IntManAdd( Hsh_IntMan_t * p, int iData ) +{ int i, * pPlace; if ( Vec_WrdSize(p->vObjs) > Vec_IntSize(p->vTable) ) { @@ -151,13 +159,14 @@ static inline int Hsh_IntManAdd( Hsh_IntMan_t * p, int iData ) Hsh_IntObj(p, i)->iNext = *pPlace; *pPlace = i; } } - pPlace = Vec_IntEntryP( p->vTable, Hsh_IntManHash(pData, p->nSize, Vec_IntSize(p->vTable)) ); - for ( ; (pObj = Hsh_IntObj(p, *pPlace)); pPlace = &pObj->iNext ) - if ( !memcmp( pData, Hsh_IntData(p, pObj->iData), sizeof(int) * p->nSize ) ) - return (word *)pObj - Vec_WrdArray(p->vObjs); - *pPlace = Vec_WrdSize(p->vObjs); - Vec_WrdPush( p->vObjs, Hsh_IntWord(iData, -1) ); - return Vec_WrdSize(p->vObjs)-1; + pPlace = Hsh_IntManLookup( p, Hsh_IntData(p, iData) ); + if ( *pPlace == -1 ) + { + *pPlace = Vec_WrdSize(p->vObjs); + Vec_WrdPush( p->vObjs, Hsh_IntWord(iData, -1) ); + return Vec_WrdSize(p->vObjs) - 1; + } + return (word *)Hsh_IntObj(p, *pPlace) - Vec_WrdArray(p->vObjs); } /**Function************************************************************* -- cgit v1.2.3