
For example, this commit moves the 'throw' branch of an assertion (nil check, slice index check, etc) to the end of the function while inserting the "continue" branch right after the insert location. This makes the resulting IR easier to follow. For some reason, this also reduces code size a bit on average. The TinyGo smoke tests saw a reduction of 0.22%, mainly from WebAssembly. The drivers repo saw little average change in code size (-0.01%). This commit also adds a few compiler tests for the defer keyword.
20 строки
200 Б
Go
20 строки
200 Б
Go
package main
|
|
|
|
func external()
|
|
|
|
func deferSimple() {
|
|
defer func() {
|
|
print(3)
|
|
}()
|
|
external()
|
|
}
|
|
|
|
func deferMultiple() {
|
|
defer func() {
|
|
print(3)
|
|
}()
|
|
defer func() {
|
|
print(5)
|
|
}()
|
|
external()
|
|
}
|