Example #1
0
 /// <summary>Write byte into byte slice stream </summary>
 public void  WriteByte(byte b)
 {
     System.Diagnostics.Debug.Assert(slice != null);
     if (slice[upto] != 0)
     {
         upto    = pool.AllocSlice(slice, upto);
         slice   = pool.buffer;
         offset0 = pool.byteOffset;
         System.Diagnostics.Debug.Assert(slice != null);
     }
     slice[upto++] = b;
     System.Diagnostics.Debug.Assert(upto != slice.Length);
 }
Example #2
0
        internal void  WriteByte(int stream, byte b)
        {
            int upto = intUptos[intUptoStart + stream];

            byte[] bytes = bytePool.buffers[upto >> DocumentsWriter.BYTE_BLOCK_SHIFT];
            System.Diagnostics.Debug.Assert(bytes != null);
            int offset = upto & DocumentsWriter.BYTE_BLOCK_MASK;

            if (bytes[offset] != 0)
            {
                // End of slice; allocate a new one
                offset = bytePool.AllocSlice(bytes, offset);
                bytes  = bytePool.buffer;
                intUptos[intUptoStart + stream] = offset + bytePool.byteOffset;
            }
            bytes[offset] = b;
            (intUptos[intUptoStart + stream])++;
        }