internal void WriteLong(long v, TdsParserStateObject stateObj)
{
if ((stateObj._outBytesUsed + 8) > stateObj._outBuff.Length)
{
// if all of the long doesn't fit into the buffer
for (int shiftValue = 0; shiftValue < sizeof(long) * 8; shiftValue += 8)
{
stateObj.WriteByte((byte)((v >> shiftValue) & 0xff));
}
}
else
{
// all of the long fits into the buffer
// NOTE: We don't use a loop here for performance
stateObj._outBuff[stateObj._outBytesUsed] = (byte)(v & 0xff);
stateObj._outBuff[stateObj._outBytesUsed + 1] = (byte)((v >> 8) & 0xff);
stateObj._outBuff[stateObj._outBytesUsed + 2] = (byte)((v >> 16) & 0xff);
stateObj._outBuff[stateObj._outBytesUsed + 3] = (byte)((v >> 24) & 0xff);
stateObj._outBuff[stateObj._outBytesUsed + 4] = (byte)((v >> 32) & 0xff);
stateObj._outBuff[stateObj._outBytesUsed + 5] = (byte)((v >> 40) & 0xff);
stateObj._outBuff[stateObj._outBytesUsed + 6] = (byte)((v >> 48) & 0xff);
stateObj._outBuff[stateObj._outBytesUsed + 7] = (byte)((v >> 56) & 0xff);
stateObj._outBytesUsed += 8;
}
}