Joe Tsai

Results 380 comments of Joe Tsai

Here's an example of a diff that got worse: ``` got: [][]uint8{ - {0xde, 0xad, 0xbe, 0xef}, {0xff, 0x6f, 0x6f}, + "foo", "barbaz", bytes.Join({ - "bl", "a", - "hdieblah", +...

If you look at the implementation, it's a lot of hardcoded constants and heuristics. It is infeasible to expose all of those details through options. It's better to look at...

Thanks for the bug report. We're performing a diff on byte boundaries rather than rune boundaries. We can fix the heuristic for this where we use rune diffing if the...

This is highly specialized and I don't think there needs to be first-class support for it in `cmp`. You can accomplish this yourself [using a custom `Reporter`](https://pkg.go.dev/github.com/google/go-cmp/cmp#Reporter). The output of...

@nhooyr, how do you see this as a Go 1 compatibility issue? Whether `io.CopyBuffer` chooses to use ReadFrom or WriteTo or not does not alter the correctness of the function....

> Its documented behavior that io.CopyBuffer behaves identically to io.Copy except it stages through the provided buffer rather than allocating a temporary one. By changing io.CopyBuffer we may break this...

Just noting here that [`strings.Reader.WriteTo`](https://github.com/golang/go/blob/acc757f678a42ba1ffbf8bb9886de4fe080302de/src/strings/reader.go#L133-L141) is another example of an implementation of `io.WriterTo` that is not efficient in all circumstances. It relies on [`io.WriteString`](https://github.com/golang/go/blob/acc757f678a42ba1ffbf8bb9886de4fe080302de/src/io/io.go#L295-L300), which only calls `WriteString` if the...

My original post contained the hack to get around this issue: ``` go io.CopyBuffer(struct{ io.Writer }{dst}, struct{ io.Reader }{src}, buf) ``` It's just not an intuitive hack to most people....

Yes, #13848 was filed when I observed a large string was unnecessarily being copied. This issue was filed on behalf of someone who noticed performance issues in an internal system.

Not performance related, but http://golang.org/cl/31174 is another case where the behavior of `io.CopyBuffer` was unexpected. The test relied upon copy being done in specific chunk sizes.