Re: [go-nuts] Re: Why is there a slow-down to split one method of a struct pointer into two methods?

2017-10-08 Thread Jan Mercl
On Sun, Oct 8, 2017 at 8:02 PM Zack Scholl wrote: > Why does it slow down the code if its not inlined? Since the method is on a pointer struct I assume it wouldn't need to copy anything? Call/return is not free even before stack limit checking, pushing the arguments and

[go-nuts] Re: Why is there a slow-down to split one method of a struct pointer into two methods?

2017-10-08 Thread Zack Scholl
Why does it slow down the code if its not inlined? Since the method is on a pointer struct I assume it wouldn't need to copy anything? I'd like to not use inlining because I need the code of this function to be used by two different functions and would rather not have to update the code twice

[go-nuts] Re: Why is there a slow-down to split one method of a struct pointer into two methods?

2017-10-08 Thread as
Take the loop and put it inside the function call. Don't make function calls in the body of a hot loop, take advantage of the loop optimizations in the runtime and your cpu cache. On Sunday, October 8, 2017 at 3:57:04 AM UTC-7, Zack Scholl wrote: > > Why is it that when I a method on an struct

[go-nuts] Re: Why is there a slow-down to split one method of a struct pointer into two methods?

2017-10-08 Thread Uli Kunitz
A function call per input byte will slow your code down unless the function is inlined. The for loop is quite simple so I wonder why you want to separate it. You should also think about whether you want to replace the process method by a Write method, making your object an io.Writer and much