i have a type, just a named wrapper for a built-in, that amongst other 
things, changes the default print output.

for example to hex,(not actual code)

type Uint64 uint64

// string rep as hexadecimal, implementing Stringer
func (x Uint64) String() string{
    return fmt.Sprintf("% X",x)
}

then i moved this to an external package, and was surprised it really 
slowed down. (-30%)

(i'm doing a lot of conversions from uint64 to Uint64 in a tight loop, i 
assumed it was 'free'.)

tried various things, and really as a last resort, because i thought it was 
just syntactic sugar, used go1.9 type aliasing;

ie instead of

import "package"

var v1 uint64
// loop
    v2:=package.Uint64(v1)

i did

import "package"

type localType = package.Uint64

var v1 uint64
// loop
    v2:=localType(v1)
    
    
toggling one line i got my original performance back?

so type aliasing not just aliasing?

i expected the same compilation.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to