public static CharsRef Join(string[] words, CharsRef reuse)
{
int upto = 0;
char[] buffer = reuse.Chars;
foreach (string word in words)
{
int wordLen = word.Length;
int needed = (0 == upto ? wordLen : 1 + upto + wordLen); // Add 1 for WORD_SEPARATOR
if (needed > buffer.Length)
{
reuse.Grow(needed);
buffer = reuse.Chars;
}
if (upto > 0)
{
buffer[upto++] = SynonymMap.WORD_SEPARATOR;
}
word.CopyTo(0, buffer, upto, wordLen - 0);
upto += wordLen;
}
reuse.Length = upto;
return reuse;
}