找回密码
 点一下
查看: 1178|回复: 6

为什么BJ函数里local都不set null的

[复制链接]
发表于 2008-12-18 15:31:12 | 显示全部楼层 |阅读模式
比如这个

function PolledWait takes real duration returns nothing
    local timer t
    local real  timeRemaining

    if (duration > 0) then
        set t = CreateTimer()
        call TimerStart(t, duration, false, null)
        loop
            set timeRemaining = TimerGetRemaining(t)
            exitwhen timeRemaining <= 0

            // If we have a bit of time left, skip past 10% of the remaining
            // duration instead of checking every interval, to minimize the
            // polling on long waits.
            if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then
                call TriggerSleepAction(0.1 * timeRemaining)
            else
                call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
            endif
        endloop
        call DestroyTimer(t)
    endif
endfunction
发表于 2008-12-18 16:38:26 | 显示全部楼层
这就是为什么用推荐用J的原因。
回复

使用道具 举报

发表于 2008-12-18 17:50:03 | 显示全部楼层
暴雪鱼妹...没注意这类吧- -...或者忘了设置...
回复

使用道具 举报

发表于 2008-12-18 23:22:04 | 显示全部楼层
timer破坏掉了啊
real不用管...
回复

使用道具 举报

发表于 2008-12-18 23:23:53 | 显示全部楼层
破坏掉最好还是要设空的
回复

使用道具 举报

发表于 2008-12-19 12:48:21 | 显示全部楼层
不设置空的话,句柄还在。。。。。增加检索的复杂性
回复

使用道具 举报

发表于 2008-12-19 18:45:21 | 显示全部楼层
所以要尽量减少BJ函数的调用
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-7-21 12:26 , Processed in 0.060867 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表