Foxtable(狐表)用户栏目专家坐堂 → 一直困扰的问题


  共有2502人关注过本帖平板打印复制链接

主题:一直困扰的问题

帅哥哟,离线,有人找我吗?
hbhb
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐神 帖子:5055 积分:13047 威望:0 精华:0 注册:2014/5/15 21:34:00
一直困扰的问题  发帖心情 Post By:2015/7/31 13:25:00 [只看该作者]

大师:代码的优化的标准是什么?是运行效率?还是代码量?代码量与运行效率有无关系。
如if语句:
 if a = true then
    dim n as Integer
     for each c as col in tables.cols
       n = n + 1
     next
     if n >= 5 then
       Output.Show("好")
     else
       Output.Show("不好")
     end if

else
     dim n as Integer
     for each c as col in tables.cols
       n = n + 1
     next
      if n >= 5 then
      Output.Show("不好")
      else
      Output.Show("好")
      end if
 end if 

与以下语句有无差别?
    dim n as Integer
     for each c as col in tables.cols
       n = n + 1
     next
     if n >= 5 then
       if a = true then
       Output.Show("好")
      else
     Output.Show("不好")
      end if
     else
       if a = true then
       Output.Show("不好")
      else
     Output.Show("好")
      end if
       
     end if

红色部分原来代码,加一个条件判断,用上面的简单,但代码量多一些?是否影响运行效率?






 回到顶部