/// <summary> /// Copy <code>src[srcPos:srcPos+len]</code> into /// <code>dest[destPos:destPos+len]</code> using at most <code>mem</code> /// bytes. /// </summary> public static void Copy(Reader src, int srcPos, Mutable dest, int destPos, int len, int mem) { Debug.Assert(srcPos + len <= src.Size()); Debug.Assert(destPos + len <= dest.Size()); int capacity = (int)((uint)mem >> 3); if (capacity == 0) { for (int i = 0; i < len; ++i) { dest.Set(destPos++, src.Get(srcPos++)); } } else if (len > 0) { // use bulk operations long[] buf = new long[Math.Min(capacity, len)]; Copy(src, srcPos, dest, destPos, len, buf); } }