File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
examples/singleapp/staticcheck_SA6002 Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -13,3 +13,21 @@ BenchmarkStaticCheckSA6002/pool-sa6002-ng-16 2852 5542
1313PASS
1414ok 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+ ```
You can’t perform that action at this time.
0 commit comments