小编jri*_*rdo的帖子

如何在AppleScript中的处理程序中有效地构建列表?

AppleScript文档建议以下代码有效地构建列表:

set bigList to {}
set bigListRef to a reference to bigList
set numItems to 100000
set t to (time of (current date)) --Start timing operations
repeat with n from 1 to numItems
    copy n to the end of bigListRef
end
set total to (time of (current date)) - t --End timing
Run Code Online (Sandbox Code Playgroud)

注意使用显式引用.这在脚本的顶级或显式运行处理程序中工作正常,但如果您在另一个处理程序中逐字运行相同的完全代码,如下所示:

on buildList()
    set bigList to {}
    set bigListRef to a reference to bigList
    set numItems to 100000
    set t to (time of (current date)) --Start timing operations …
Run Code Online (Sandbox Code Playgroud)

performance applescript reference list handler

5
推荐指数
1
解决办法
198
查看次数

标签 统计

applescript ×1

handler ×1

list ×1

performance ×1

reference ×1