Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ahsonkhan's full-sized avatar
💭
Working to empower every developer on the planet to achieve more.

Ahson Khan ahsonkhan

💭
Working to empower every developer on the planet to achieve more.
  • Microsoft
View GitHub Profile
@ahsonkhan
ahsonkhan / IntParserUnrolled.md
Last active June 24, 2017 04:23
Loop unrolled int 32 parser
public static bool TryParseInt32(ReadOnlySpan<byte> text, out int value, out int bytesConsumed)
{
    int textLength = text.Length;
    if (textLength < 1) goto FalseExit;

    int sign = 1;
    int index = default;
    int num = text[index];
@ahsonkhan
ahsonkhan / System.Text.Primitives.md
Last active June 19, 2017 01:37
System.Text.Primitives API Review
namespace System.Buffers.Text {
    public static class Base64 {
        public static int ComputeDecodedLength(ReadOnlySpan<byte> source);
        public static int ComputeEncodedLength(int sourceLength);
        public static TransformationStatus Decode(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesConsumed, out int bytesWritten);
        public static TransformationStatus DecodeInPlace(Span<byte> buffer, out int bytesConsumed, out int bytesWritten);
        public static TransformationStatus Encode(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesConsumed, out int bytesWritten);
        public static TransformationStatus EncodeInPlace(Span<byte> buffer, int sourceLength, out int bytesWritten);
    }
@ahsonkhan
ahsonkhan / job-testLinux-16-console.txt
Created May 9, 2017 22:06
job-testLinux-16-console.txt
Started by user Ahson Khan
Building in workspace C:\Program Files (x86)\Jenkins\workspace\testLinux
> git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git.exe config remote.origin.url https://github.com/dotnet/dotnet-ci # timeout=10
Fetching upstream changes from https://github.com/dotnet/dotnet-ci
> git.exe --version # timeout=10
> git.exe fetch --tags --progress https://github.com/dotnet/dotnet-ci +refs/heads/*:refs/remotes/origin/* # timeout=30
> git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
> git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
@ahsonkhan
ahsonkhan / SpanSliceIndexOf.md
Last active March 11, 2017 02:12
Comparing Span Slice then IndexOf vs using an IndexOf overload that takes index and count

Here are the latest results and conclusion.

Essentially, for Span specifically, calling Slice then IndexOf is just as good (if not better) than calling the IndexOf overload which removes the need to Slice.

dotnet/corefxlab#1278

(I am limiting the discussion to fast span since the conclusion doesn’t generally change for slow span)

image