public bool Append(Pointer ip, int len) { int spaceLeft = _length - _index; if (spaceLeft < len) { return(false); } var op = new Pointer(_buffer, _index); op.Copy(ip, len); _index += len; return(true); }
private static Pointer EmitLiteral(Pointer dest, Pointer literal, int length, bool allowFastPath) { int n = length - 1; if (n < 60) { var value = CompressorTag.Literal | (n << 2); dest[0] = (byte)value; dest += 1; if (allowFastPath && length <= 16) { dest.Copy64(literal); dest.Copy64(literal + 8, offset: 8); return(dest + length); } } else { var tmp = new Pointer(dest); dest += 1; int count = 0; while (n > 0) { dest[count] = (byte)(n & 0xff); n >>= 8; count++; } Debug.Assert(count >= 1); Debug.Assert(count <= 4); tmp[0] = (byte)(CompressorTag.Literal | (59 + count) << 2); dest += count; } dest.Copy(literal, length); return(dest + length); }