apm-server icon indicating copy to clipboard operation
apm-server copied to clipboard

Shouldn't payload be a pointer

Open nexthack opened this issue 9 years ago • 4 comments

At this line,shouldn't the payload be a pointer.

Similarly at this line ,I think the data should be a pointer as we are passing p.payload.

nexthack avatar Aug 20 '17 21:08 nexthack

Hi @crackerplace. Happy to see you get involved with apm-server.

The first payload you mentioned is an interface. So I think passing it here as is should work as expected or do you see any unwanted side affects?

For the second line you mentioned it's passed as value as we only extract the data and don't modify it. Passing it by pointer would also work but I prefer in general if not pointer is need to pass a copy except it would become a performance issue.

ruflin avatar Aug 21 '17 06:08 ruflin

@ruflin thanks,Would be happy to contribute :-)

Sounds fine as we are passing a pointer to the struct payload which satisfies pr.Payload.

A simple better change would be to make payload as lower case at line as we are anywayz assigning it to an interface and need not be exported.It helps in understanding as well.What do you think ?

nexthack avatar Aug 21 '17 20:08 nexthack

Making it private SGTM assuming we don't need it anywhere else. Can you open a PR?

ruflin avatar Aug 22 '17 07:08 ruflin

@ruflin Sure.Will open.

nexthack avatar Aug 22 '17 19:08 nexthack