Skip to content

Instantly share code, notes, and snippets.

@shanemhansen
Created December 14, 2017 16:50
Show Gist options
  • Save shanemhansen/cb9cbf657499e351615cb22a30765112 to your computer and use it in GitHub Desktop.
Save shanemhansen/cb9cbf657499e351615cb22a30765112 to your computer and use it in GitHub Desktop.
Comparisong of string=="" vs len(string) == 0
"".TestEmpty STEXT nosplit size=22 args=0x18 locals=0x0
0x0000 00000 (/home/shansen/foo.go:14) TEXT "".TestEmpty(SB), NOSPLIT, $0-24
0x0000 00000 (/home/shansen/foo.go:14) FUNCDATA $0, gclocals·d4dc2f11db048877dbc0f60a22b4adb3(SB)
0x0000 00000 (/home/shansen/foo.go:14) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (/home/shansen/foo.go:14) MOVQ "".val+16(SP), AX
0x0005 00005 (/home/shansen/foo.go:15) TESTQ AX, AX
0x0008 00008 (/home/shansen/foo.go:15) JNE 16
0x000a 00010 (/home/shansen/foo.go:16) MOVB $1, "".~r1+24(SP)
0x000f 00015 (/home/shansen/foo.go:16) RET
0x0010 00016 (/home/shansen/foo.go:18) MOVB $0, "".~r1+24(SP)
0x0015 00021 (/home/shansen/foo.go:18) RET
0x0000 48 8b 44 24 10 48 85 c0 75 06 c6 44 24 18 01 c3 H.D$.H..u..D$...
0x0010 c6 44 24 18 00 c3 .D$...
"".TestLen STEXT nosplit size=22 args=0x18 locals=0x0
0x0000 00000 (/home/shansen/foo.go:21) TEXT "".TestLen(SB), NOSPLIT, $0-24
0x0000 00000 (/home/shansen/foo.go:21) FUNCDATA $0, gclocals·d4dc2f11db048877dbc0f60a22b4adb3(SB)
0x0000 00000 (/home/shansen/foo.go:21) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (/home/shansen/foo.go:21) MOVQ "".val+16(SP), AX
0x0005 00005 (/home/shansen/foo.go:22) TESTQ AX, AX
0x0008 00008 (/home/shansen/foo.go:22) JNE 16
0x000a 00010 (/home/shansen/foo.go:23) MOVB $1, "".~r1+24(SP)
0x000f 00015 (/home/shansen/foo.go:23) RET
0x0010 00016 (/home/shansen/foo.go:25) MOVB $0, "".~r1+24(SP)
0x0015 00021 (/home/shansen/foo.go:25) RET
0x0000 48 8b 44 24 10 48 85 c0 75 06 c6 44 24 18 01 c3 H.D$.H..u..D$...
0x0010 c6 44 24 18 00 c3 .D$...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment