diff options
| author | Rémy Oudompheng <oudomphe@phare.normalesup.org> | 2012-08-05 21:35:41 +0200 |
|---|---|---|
| committer | Rémy Oudompheng <oudomphe@phare.normalesup.org> | 2012-08-05 21:35:41 +0200 |
| commit | 77f3e189d2bd4eb015235d200ca75803e45c87ef (patch) | |
| tree | 76a992e3dbc8ae3170f5e28917bbefd7a6c0178c /src/pkg/runtime/alg.c | |
| parent | ab058b35402aded8579e3e9653c0d78c5c4e9e5e (diff) | |
| download | go-77f3e189d2bd4eb015235d200ca75803e45c87ef.tar.xz | |
runtime: faster string equality.
benchmark old ns/op new ns/op delta
BenchmarkCompareStringEqual 51 35 -30.20%
BenchmarkCompareStringIdentical 51 7 -85.71%
BenchmarkCompareStringSameLength 25 18 -28.29%
BenchmarkCompareStringDifferentLength 2 2 +1.46%
R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6450092
Diffstat (limited to 'src/pkg/runtime/alg.c')
| -rw-r--r-- | src/pkg/runtime/alg.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pkg/runtime/alg.c b/src/pkg/runtime/alg.c index bc848da38c..ce872755ff 100644 --- a/src/pkg/runtime/alg.c +++ b/src/pkg/runtime/alg.c @@ -324,6 +324,10 @@ runtime·strequal(bool *eq, uintptr s, void *a, void *b) *eq = false; return; } + if(((String*)a)->str == ((String*)b)->str) { + *eq = true; + return; + } runtime·memequal(eq, alen, ((String*)a)->str, ((String*)b)->str); } |
