dbertoni    00/07/10 15:45:46

  Modified:    c/src/PlatformSupport XalanBitmap.cpp XalanBitmap.hpp
  Log:
  Use statically-built masks.
  
  Revision  Changes    Path
  1.2       +11 -5     xml-xalan/c/src/PlatformSupport/XalanBitmap.cpp
  
  Index: XalanBitmap.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanBitmap.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XalanBitmap.cpp   2000/07/10 01:03:12     1.1
  +++ XalanBitmap.cpp   2000/07/10 22:45:46     1.2
  @@ -63,9 +63,15 @@
   
   
   
  +// Pre-constructed masks for bit twiddling.  Update these if not using chars 
for storing the bits.
  +static const int     theSetMasks[XalanBitmap::eBitsPerUnit] = { 1, 2, 4, 8, 
16, 32, 64, 128 };
  +static const int     theClearMasks[XalanBitmap::eBitsPerUnit] = { ~1, ~2, 
~4, ~8, ~16, ~32, ~64, ~128 };
  +
  +
  +
   XalanBitmap::XalanBitmap(unsigned long       theSize) :
        m_size(theSize),
  -     m_bitmap((theSize + eBitsPerChar) / eBitsPerChar)
  +     m_bitmap((theSize + eBitsPerUnit) / eBitsPerUnit)
   {
   }
   
  @@ -86,7 +92,7 @@
        }
        else
        {
  -             return m_bitmap[theBit / eBitsPerChar] & makeMask(theBit) ? 
true : false;
  +             return m_bitmap[theBit / eBitsPerUnit] & theSetMasks[theBit % 
eBitsPerUnit] ? true : false;
        }
   }
   
  @@ -97,7 +103,7 @@
   {
        if (theBit < m_size)
        {
  -             m_bitmap[theBit / eBitsPerChar] |= makeMask(theBit);
  +             m_bitmap[theBit / eBitsPerUnit] |= theSetMasks[theBit % 
eBitsPerUnit];
        }
   }
   
  @@ -108,7 +114,7 @@
   {
        if (theBit < m_size)
        {
  -             m_bitmap[theBit / eBitsPerChar] &= ~makeMask(theBit);
  +             m_bitmap[theBit / eBitsPerUnit] &= theClearMasks[theBit % 
eBitsPerUnit];
        }
   }
   
  @@ -119,7 +125,7 @@
   {
        if (theBit < m_size)
        {
  -             m_bitmap[theBit / eBitsPerChar] ^= makeMask(theBit);
  +             m_bitmap[theBit / eBitsPerUnit] ^= theSetMasks[theBit % 
eBitsPerUnit];
        }
   }
   
  
  
  
  1.2       +12 -21    xml-xalan/c/src/PlatformSupport/XalanBitmap.hpp
  
  Index: XalanBitmap.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanBitmap.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XalanBitmap.hpp   2000/07/10 01:03:12     1.1
  +++ XalanBitmap.hpp   2000/07/10 22:45:46     1.2
  @@ -72,7 +72,17 @@
   {
   public:
   
  +     // The basic storage unit for the bitmaps.
  +     typedef char    UnitType;
   
  +     // Really all we're assuming is that a char is at least
  +     // 8 bits.  If it's more, then we'll just waste some
  +     // space.  This may need to be adjusted for various
  +     // platforms, or perhaps change to using an integral of
  +     // a known size, so that we don't waste any space.
  +     enum { eBitsPerUnit = 8 };
  +
  +
        /**
         * Construct an instance with room for the specified number
         * of bits.
  @@ -136,29 +146,10 @@
   
   private:
   
  -     // Really all we're assuming is that a char is at least
  -     // 8 bits.  If it's more, then we'll just waste some
  -     // space.  This may need to be adjusted for various
  -     // platforms, or perhaps change to using an integral of
  -     // a known size.
  -     enum { eBitsPerChar = 8 };
  -
  -     /**
  -      * Make a mask to manipulate a bit.
  -      *
  -      * @param The number of the bit
  -      * @return The mask
  -      */
  -     static char
  -     makeMask(unsigned long  theBit)
  -     {
  -             return char(1 << (theBit % eBitsPerChar));
  -     }
  -
   #if defined(XALAN_NO_NAMESPACES)
  -     typedef vector<char>            BitmapVectorType;
  +     typedef vector<UnitType>                BitmapVectorType;
   #else
  -     typedef std::vector<char>       BitmapVectorType;
  +     typedef std::vector<UnitType>   BitmapVectorType;
   #endif
   
        const unsigned long             m_size;
  
  
  

Reply via email to