if (tdsVersion < TdsVersion.tds70) {
Append (encoder.GetBytes (s));
} else {
- int cindex = 0, index;
- int ssize = sizeof (short);
- int lenToWrite = s.Length * ssize;
- // if nextOutBufferLength points to the last buffer in outBuffer,
- // we would get a DivisionByZero while calculating remBufLen
- if (outBufferLength - nextOutBufferIndex < ssize)
- SendIfFull (ssize);
-
- int remBufLen = outBufferLength - nextOutBufferIndex;
- int count = lenToWrite/remBufLen;
-
- if (lenToWrite % remBufLen > 0)
- count++;
-
- for (int i = 0; i < count; i++) {
- index = System.Math.Min (remBufLen/ssize, lenToWrite/ssize);
- for (int j = 0; j < index*ssize; j+=2, cindex++)
- AppendInternal ((short)s[cindex]);
-
- lenToWrite -= index*ssize;
- // Just make sure to flush the buffer
- SendIfFull ((lenToWrite+1)*ssize);
+ for (int i = 0; i < s.Length; i++) {
+ SendIfFull (sizeof(short));
+ AppendInternal ((short)s[i]);
}
}
}