text: public long CopyUsingLengthPrefix(BytesRef bytes){if (bytes.Length >= 32768){throw new System.ArgumentException("max length is 32767 (got " + bytes.Length + ")");}if (upto + bytes.Length + 2 > blockSize){if (bytes.Length + 2 > blockSize){throw new System.ArgumentException("block size " + blockSize + " is too small to store length " + bytes.Length + " bytes");}if (currentBlock != null){blocks.Add(currentBlock);blockEnd.Add(upto);}currentBlock = new byte[blockSize];upto = 0;}long pointer = GetPointer();if (bytes.Length < 128){currentBlock[upto++] = (byte)bytes.Length;}else{currentBlock[upto++] = unchecked((byte)(0x80 | (bytes.Length >> 8)));currentBlock[upto++] = unchecked((byte)(bytes.Length & 0xff));}Array.Copy(bytes.Bytes, bytes.Offset, currentBlock, upto, bytes.Length);upto += bytes.Length;return pointer;}