Skip to content

Commit 3fdcc93

Browse files
authored
Update README.md
1 parent 2a34ef5 commit 3fdcc93

File tree

1 file changed

+18
-0
lines changed
  • examples/singleapp/staticcheck_SA6002

1 file changed

+18
-0
lines changed

examples/singleapp/staticcheck_SA6002/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,21 @@ BenchmarkStaticCheckSA6002/pool-sa6002-ng-16 2852 5542
1313
PASS
1414
ok github.com/devlights/try-golang/examples/singleapp/staticcheck_SA6002 5.699s
1515
```
16+
17+
https://github.com/dominikh/go-tools/issues/1336#issuecomment-1331206290 のコードコメントの日本語訳
18+
19+
```
20+
// You might be tempted to simplify this by just passing &outBuf to Put,
21+
// but that would make the local copy of the outBuf slice header escape
22+
// to the heap, causing an allocation. Instead, we keep around the
23+
// pointer to the slice header returned by Get, which is already on the
24+
// heap, and overwrite and return that.
25+
```
26+
27+
```
28+
// ここで &outBuf を Put に渡すことで簡略化したくなるかもしれませんが、
29+
// それでは outBuf スライスヘッダのローカルコピーがヒープに逃げてしまい、
30+
// メモリアロケーションが発生してしまいます。代わりに、Get によって返される
31+
// スライスヘッダへのポインタを保持し、それを上書きして返します。
32+
// そのポインタはすでにヒープ上にあります。
33+
```

0 commit comments

Comments
 (0)