PB代码优化(2)


第二种情况:

IF NOT condition THEN

//Code goes here.

END IF

IF condition THEN

//No code goes here.

ELSE

//Code goes here.

END IF

对于上一种方式,条件表达式返回 false 并且再进行一个 非 运算,才执行下面的代码。这样相对于下面一种书写方式可能多执行了一个 非 运算。如果大家有什么疑问,您不妨测试一下下面这个例子:

// 小测试:其中的判断条件只是为了表示一下,实际情况可能更复杂。

long i // 计数器

long ll_start // 执行开始时间

long ll_used1 // 方式一耗时

long ll_used2 // 方式二耗时

// 方式一

ll_start = Cpu()

for i = 1 to 900000

if not (1 > 1) Then

i = i

end if

next

ll_used1 = Cpu() - ll_start

Published At
Categories with 数据库类
comments powered by Disqus