Avatar
Kishikawa Katsumi 8/1/2023 4:29 PM
SwiftSyntax tries to minimize the use of existentials (aka. protocols spelled with any or protocols spelled without some) wherever possible. This is because when the stored value is more than 3 words (a word is the size of a pointer) large, these existentials store their data on the heap. The data stored inside RawSyntax is larger than 3 words and thus every time you pass a value around as a e.g. an ExprSyntaxProtocol, a new heap allocation will be made and that data needs to be reference-counted, which causes a very noticeable performance overhead.
SwiftSyntaxのドキュメント読んでたらこの記述に出会ったのだけど、3ワード以上の大きさだったらメモリがヒープに確保されるっていうのこれ以外に記述あるかな?
4:30 PM
apple/swiftリポジトリのドキュメントのどこかにも書いてあった方がいいんじゃないかなって。