]> Cypherpunks repositories - gostls13.git/commit
net: avoid string operation and make valid domain names explicit
authorVolker Dobler <dr.volker.dobler@gmail.com>
Thu, 8 Aug 2013 23:33:57 +0000 (16:33 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 8 Aug 2013 23:33:57 +0000 (16:33 -0700)
commit654f35865fbbb595593e245887e58ba50d213f9c
treeac2208b25e559252e11d6099322efb02e118d802
parent6e5f4bab90456e845d2e4a436718d4ab4cfee238
net: avoid string operation and make valid domain names explicit

Having a trailing dot in the string doesn't really simplify
the checking loop in isDomainName. Avoid this unnecessary allocation.
Also make the valid domain names more explicit by adding some more
test cases.

benchmark            old ns/op    new ns/op    delta
BenchmarkDNSNames       2420.0        983.0  -59.38%

benchmark           old allocs   new allocs    delta
BenchmarkDNSNames           12            0  -100.00%

benchmark            old bytes    new bytes    delta
BenchmarkDNSNames          336            0  -100.00%

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12662043
src/pkg/net/dnsclient.go
src/pkg/net/dnsname_test.go