summaryrefslogtreecommitdiffstats
path: root/src/misc/vec/vecHsh.h
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2013-05-30 09:46:13 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2013-05-30 09:46:13 -0700
commit67127b838d935876a879b1ced82f45de8e47621f (patch)
tree102a65fb24729113ca8775223f9002b34d281118 /src/misc/vec/vecHsh.h
parentc50c1fc662a2068227e9f39817a6bf499a0efb29 (diff)
downloadabc-67127b838d935876a879b1ced82f45de8e47621f.tar.gz
abc-67127b838d935876a879b1ced82f45de8e47621f.tar.bz2
abc-67127b838d935876a879b1ced82f45de8e47621f.zip
New DSD detection code.
Diffstat (limited to 'src/misc/vec/vecHsh.h')
-rw-r--r--src/misc/vec/vecHsh.h27
1 files changed, 18 insertions, 9 deletions
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*************************************************************