-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime: rewrite 'appendCap' function and use old cap instead of len
This change implements the commit golang/go@2333c62 in Scriggo. For #385
- Loading branch information
Showing
2 changed files
with
32 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
test/compare/testdata/github.com-golang-go/fixedbugs/issue41239.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// run | ||
|
||
// Copyright 2020 The Go Authors. All rights reserved. Use of this | ||
// source code is governed by a BSD-style license that can be found in | ||
// the LICENSE file. | ||
|
||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
const N = 1024 | ||
var a [N]int | ||
x := cap(append(a[:N-1:N], 9, 9)) | ||
y := cap(append(a[:N:N], 9)) | ||
if x != y { | ||
panic(fmt.Sprintf("different capacity on append: %d vs %d", x, y)) | ||
} | ||
} |