• Volker Dobler's avatar
    net: avoid string operation and make valid domain names explicit · 654f3586
    Volker Dobler authored
    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
    654f3586
dnsclient.go 5.94 KB