Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Private Attributes
nsCompressedMap Class Reference

List of all members.

Public Member Functions

 nsCompressedMap (const PRUnichar *aTable, PRUint32 aSize)
 ~nsCompressedMap ()
PRUnichar Map (PRUnichar aChar)

Protected Member Functions

PRUnichar Lookup (PRUint32 l, PRUint32 m, PRUint32 r, PRUnichar aChar)

Private Attributes

const PRUnicharmTable
PRUint32 mSize
PRUint32mCache
PRUint32 mLastBase

Detailed Description

Definition at line 71 of file nsCaseConversionImp2.cpp.


Constructor & Destructor Documentation

Definition at line 86 of file nsCaseConversionImp2.cpp.

Definition at line 97 of file nsCaseConversionImp2.cpp.


Member Function Documentation

PRUnichar nsCompressedMap::Lookup ( PRUint32  l,
PRUint32  m,
PRUint32  r,
PRUnichar  aChar 
) [protected]

Definition at line 142 of file nsCaseConversionImp2.cpp.

{
  PRUint32 base = m*3;
  if ( aChar >  ((mTable[base+kSizeEveryIdx] >> 8) + 
                 mTable[base+kLowIdx])) 
  {
    if( l > m )
      return aChar;
    PRUint32 newm = (m+r+1)/2;
    if(newm == m)
          newm++;
    return this->Lookup(m+1, newm , r, aChar);
    
  } else if ( mTable[base+kLowIdx]  > aChar ) {
    if( r < m )
      return aChar;
    PRUint32 newm = (l+m-1)/2;
    if(newm == m)
          newm++;
       return this->Lookup(l, newm, m-1, aChar);

  } else  {
    if(((mTable[base+kSizeEveryIdx] & 0x00FF) > 0) && 
       (0 != ((aChar - mTable[base+kLowIdx]) % 
              (mTable[base+kSizeEveryIdx] & 0x00FF))))
    {
       return aChar;
    }
    mLastBase = base; // cache the base
    return aChar + mTable[base+kDiffIdx];
  }
}

Here is the caller graph for this function:

Definition at line 103 of file nsCaseConversionImp2.cpp.

{
   // no need to worry thread since cached value are 
   // not object but primitive data type which could be 
   // accessed in atomic operation. We need to access
   // the whole 32 bit of cachedData at once in order to make it
   // thread safe. Never access bits from mCache dirrectly

   PRUint32 cachedData = mCache[aChar & CASE_MAP_CACHE_MASK];
   if(aChar == ((cachedData >> 16) & 0x0000FFFF))
     return (cachedData & 0x0000FFFF);

   // try the last index first
   // store into local variable so we can be thread safe
   PRUint32 base = mLastBase; 
   PRUnichar res = 0;
 
   if (( aChar <=  ((mTable[base+kSizeEveryIdx] >> 8) + 
                 mTable[base+kLowIdx])) &&
       ( mTable[base+kLowIdx]  <= aChar )) 
   {
      // Hit the last base
      if(((mTable[base+kSizeEveryIdx] & 0x00FF) > 0) && 
         (0 != ((aChar - mTable[base+kLowIdx]) % 
               (mTable[base+kSizeEveryIdx] & 0x00FF))))
      {
         res = aChar;
      } else {
         res = aChar + mTable[base+kDiffIdx];
      }
   } else {
      res = this->Lookup(0, (mSize/2), mSize-1, aChar);
   }

   mCache[aChar & CASE_MAP_CACHE_MASK] =
       (((aChar << 16) & 0xFFFF0000) | (0x0000FFFF & res));
   return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 82 of file nsCaseConversionImp2.cpp.

Definition at line 83 of file nsCaseConversionImp2.cpp.

Definition at line 81 of file nsCaseConversionImp2.cpp.

Definition at line 80 of file nsCaseConversionImp2.cpp.


The documentation for this class was generated from the following file: