Hi,
Just check if backing array are same before copying:
https://play.golang.org/p/MSqs-jRkSO

On Thursday, September 7, 2017 at 8:54:16 AM UTC+3, Deepak Jois wrote:
>
> Hi 
>
> Pls look at this code: https://play.golang.org/p/QfQOo1iyp4 
>
> I am copying a slice over itself. How does it work internally? Does 
> the copy operation optimise for this, and not perform any copying in 
> this case? 
>
> I have to deal with a situation where I get a slice reference back 
> from a function, and it is possible that it points to the same slice 
> that I am trying to copy it into. It would be nice if the copy 
> operation in that case is a no-op, but I don’t want to assume that is 
> the case. 
>
> Deepak 
>

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