ImTools icon indicating copy to clipboard operation
ImTools copied to clipboard

Review of ArrayTools to use Span, documentation, attributes

Open dzmitry-lahoda opened this issue 5 years ago • 0 comments

Span

As I understand ArrayTools consider arrays as immutable(while .NET devs have build Spans for arrays to be really immutable), may try to apply https://github.com/dadhi/ImTools/blob/56b7f53a784c3843e4299658592d7b9340153fbc/src/ImTools/ImTools.cs#L48 https://msdn.microsoft.com/en-us/magazine/mt814808.aspx?f=255&MSPPError=-2147217396 (these are only couple percentage slower)

Would you accept migration to Span in some future version?

Doc

Methods to work with immutable arrays replace with Methods to work with arrays as immutable https://github.com/dadhi/ImTools/blob/56b7f53a784c3843e4299658592d7b9340153fbc/src/ImTools/ImTools.cs#L47

Attributes

Consider something existing which on arrays:

        [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
        public static int BinarySearch<T>(T[] array, int index, int length, T value, IComparer<T> comparer);

        [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
        [SecuritySafeCritical]
        public static int LastIndexOf(Array array, object value, int startIndex, int count);

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public ReadOnlyMemory<T> Slice(int start)

dzmitry-lahoda avatar Jul 26 '18 17:07 dzmitry-lahoda