Skip to content

Instantly share code, notes, and snippets.

@nodakai
Created May 17, 2022 16:12
Show Gist options
  • Save nodakai/32b520574fde97de8d7389ab04f64bc4 to your computer and use it in GitHub Desktop.
Save nodakai/32b520574fde97de8d7389ab04f64bc4 to your computer and use it in GitHub Desktop.
open System
let spanOfOptString(os: Option<string>) =
match os with Some(s) -> s.AsSpan()
| None -> raise(Exception())
ReadOnlySpan.Empty
.assembly _
{
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, int32, int32) = (
01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00
)
.hash algorithm 0x00008004 // SHA1
.ver 0:0:0:0
}
.class private auto ansi '<Module>'
extends [System.Runtime]System.Object
{
} // end of class <Module>
.class public auto ansi abstract sealed _
extends [System.Runtime]System.Object
{
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = (
01 00 07 00 00 00 00 00
)
// Methods
.method public static
valuetype [System.Runtime]System.ReadOnlySpan`1<char> spanOfOptString (
class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1<string> os
) cil managed
{
// Method begins at RVA 0x2050
// Code size 43 (0x2b)
.maxstack 4
.locals init (
[0] class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1<string>
)
IL_0000: ldarg.0
IL_0001: brtrue.s IL_0005
IL_0003: br.s IL_0013
IL_0005: ldarg.0
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: call instance !0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1<string>::get_Value()
IL_000d: call valuetype [System.Runtime]System.ReadOnlySpan`1<char> [System.Memory]System.MemoryExtensions::AsSpan(string)
IL_0012: ret
IL_0013: ldc.i4.0
IL_0014: brfalse.s IL_001e
IL_0016: ldnull
IL_0017: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit
IL_001c: br.s IL_0024
IL_001e: newobj instance void [System.Runtime]System.Exception::.ctor()
IL_0023: throw
IL_0024: pop
IL_0025: call valuetype [System.Runtime]System.ReadOnlySpan`1<!0> valuetype [System.Runtime]System.ReadOnlySpan`1<char>::get_Empty()
IL_002a: ret
} // end of method _::spanOfOptString
} // end of class _
.class private auto ansi abstract sealed '<StartupCode$_>.$_'
extends [System.Runtime]System.Object
{
} // end of class <StartupCode$_>.$_
{
"version": 1,
"target": "IL",
"mode": "Release",
"branch": "core-x64"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment