internal void CopyFrom(ref QueryBuffer <T> addBuffer) { int addCount = addBuffer.count; switch (addCount) { default: if (addCount > buffer.Length) { buffer = new T[addCount]; } // Copy all the new elements in Array.Copy(addBuffer.buffer, 0, buffer, 0, addCount); count = addCount; break; case 0: count = 0; break; case 1: if (buffer.Length == 0) { buffer = new T[1]; } buffer[0] = addBuffer.buffer[0]; count = 1; break; } }
/// <summary> /// Add all the elements in the given buffer to this one /// We can do this very efficiently using an Array Copy /// </summary> internal void Add(ref QueryBuffer <T> addBuffer) { if (1 == addBuffer.count) { Add(addBuffer.buffer[0]); return; } int newCount = count + addBuffer.count; if (newCount >= buffer.Length) { Grow(newCount); } // Copy all the new elements in Array.Copy(addBuffer.buffer, 0, buffer, count, addBuffer.count); count = newCount; }