Why is it that when I a method on an struct pointer, like

func (s *Object) process(inputs []byte) {
    for _, i := range inputs {
        // Lots of code
    }    
}

it will slow down *a lot* if I move // Lots of code to its own function? 
I.e. I reorganize the above program two use two methods,

func (s *Object) process(inputs []byte) {
    for _, i := range inputs {
        processInput(i)
    }    
}

func (s *Object) processInput(i byte) {
    // Lots of code
}

This new code runs 30% slower now! 

Why? 

This matters because I'm in a situation in *pluck* where I need // Lots of 
code in two places. You can reproduce this in *pluck* by running


go get -u github.com/schollz/pluck
cd $GOPATH/src/github.com/schollz/pluck/pluck
git checkout ef1004f && go test -bench=Stream -run=z
git checkout 76c4e96 && go test -bench=Stream -run=z
git diff 76c4e96 ef1004f # shows that I replace lots of code with one 
function



-- 
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