根据文档如何变得更好的说法,return exit 之类的使用 c++的异常来实现的,很粗暴。
fn test1 v = (if v == true do return 1; 0)
fn test2 v = (if v == true do return 1)
fn test3 v = (if v == true then return 1 else return 0)
fn test4 v = (if v == true then 1 else 0)
(
timeStart = timeStamp()
for i = 1 to 100000 do test1 true
format "test1-%
" (timeStamp() - timeStart)
timeStart = timeStamp()
for i = 1 to 100000 do test2 true
format "test2-%
" (timeStamp() - timeStart)
timeStart = timeStamp()
for i = 1 to 100000 do test3 true
format "test3-%
" (timeStamp() - timeStart)
timeStart = timeStamp()
for i = 1 to 100000 do test4 true
format "test4-%
" (timeStamp() - timeStart)
ok
)
test1-3430
test2-71
test3-71
test4-71