1
0
mirror of https://github.com/golang/go synced 2024-11-05 12:06:15 -07:00

runtime: speed up eqstring

eqstring does not need to check the length of the strings.
Other architectures were done in a separate commit.

While we're here, add a pointer equality check.

Change-Id: Id2c8616a03a7da7037c1e9ccd56a549fc952bd98
Reviewed-on: https://go-review.googlesource.com/3956
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2015-02-05 08:23:14 -08:00
parent 135ef49fde
commit 82a761b656

View File

@ -969,30 +969,30 @@ eq:
RETURN
// eqstring tests whether two strings are equal.
// The compiler guarantees that strings passed
// to eqstring have equal length.
// See runtime_test.go:eqstring_generic for
// equivalent Go code.
TEXT runtime·eqstring(SB),NOSPLIT,$0-33
MOVD s1len+8(FP), R4
MOVD s2len+24(FP), R5
CMP R4, R5
BNE noteq
MOVD s1str+0(FP), R3
MOVD s2str+16(FP), R4
MOVD $1, R5
MOVB R5, ret+32(FP)
CMP R3, R4
BNE 2(PC)
RETURN
MOVD s1len+8(FP), R5
SUB $1, R3
SUB $1, R4
ADD R3, R5, R8
loop:
CMP R3, R8
BNE 4(PC)
MOVD $1, R3
MOVB R3, ret+32(FP)
BNE 2(PC)
RETURN
MOVBZU 1(R3), R6
MOVBZU 1(R4), R7
CMP R6, R7
BEQ loop
noteq:
MOVB R0, ret+32(FP)
RETURN