aboutsummaryrefslogtreecommitdiff
path: root/src/compress
diff options
context:
space:
mode:
authorDaniel Martí <mvdan@mvdan.cc>2020-10-16 15:05:04 +0100
committerDaniel Martí <mvdan@mvdan.cc>2020-10-16 14:23:21 +0000
commit771f5f2e487db4eb2bcf6fa1660dc8cef1feaf14 (patch)
tree6ff610c77a01baf1c44c512194fa377357214cb5 /src/compress
parent8ee4d6e1bf1e76a4eac627d5fc9b0d0332d209e2 (diff)
downloadgo-771f5f2e487db4eb2bcf6fa1660dc8cef1feaf14.tar.gz
go-771f5f2e487db4eb2bcf6fa1660dc8cef1feaf14.zip
compress/flate: revert a goto for-loop
In https://golang.org/cl/16528, a goto loop was chosen over a regular for loop since that would make the function inlinable. Thanks to the recent https://golang.org/cl/256459, for loops without a label can now be inlined. So we can undo the workaround and simplify the code. Also add the function to TestIntendedInlining, which passes both before and after the change, as expected. For #14768. Change-Id: Ie5df55a6bcb07c538ca331eef2f908807ff0b516 Reviewed-on: https://go-review.googlesource.com/c/go/+/263037 Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/compress')
-rw-r--r--src/compress/flate/dict_decoder.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/compress/flate/dict_decoder.go b/src/compress/flate/dict_decoder.go
index 71c75a065e..3b59d48351 100644
--- a/src/compress/flate/dict_decoder.go
+++ b/src/compress/flate/dict_decoder.go
@@ -160,10 +160,8 @@ func (dd *dictDecoder) tryWriteCopy(dist, length int) int {
srcPos := dstPos - dist
// Copy possibly overlapping section before destination position.
-loop:
- dstPos += copy(dd.hist[dstPos:endPos], dd.hist[srcPos:dstPos])
- if dstPos < endPos {
- goto loop // Avoid for-loop so that this function can be inlined
+ for dstPos < endPos {
+ dstPos += copy(dd.hist[dstPos:endPos], dd.hist[srcPos:dstPos])
}
dd.wrPos = dstPos