/// <summary> /// Returns a slice containing values in the specified range of the specified slice. /// If the range matches the entire slice, the input slice will be returned. /// Otherwise, a copy will be returned. /// </summary> /// <param name="slice"></param> /// <param name="index"></param> /// <param name="length"></param> /// <returns></returns> static Slice CompactSlice(Slice slice, int index, int length) { if (slice.IsCompact() && index == 0 && length == slice.Size) { return(slice); } return(Slices.CopyOf(slice, index, length)); }