有时候我们需要将某个数组清空或者说重置,我最常用的办法的是重新new一下,但是有人测试研究发现使用length=0的方法,执行效率是最高的,呵呵,原文如下:
_localArray.length = 0; // Reset the array to empty
Yesterday I was coding on a rather large application at work and I needed to reset an array I had that was stored as a member variable. My gut instinct was to just take the Array variable and set its length = 0. Although this worked I wasn't sure if it was the best way to reset an array in ActionScript 3. So I asked my friend Guy Wyatt and he sent me this performance benchmark using 100,000 iterations in an Array as a test to see the time it took to clear out this Array using various techniques.
Resetting an empty array over 100,000 iterations in a while(i--) loop
length = 0: 15 ms
splice: 157 ms
new: 145 ms
So it looks like my gut instinct was right to set the length to 0 to reset my Array. I know this isn't the most glamorous blog post but I do think it is important to think about these things while coding a large Flex application. Every little bit of optimization is crucial and can over all help yield a better functioning application.
原文来自frankieloscavio.blogspot.com
转载自:http://hydra1983.blog.163.com/blog/static/11175037200862810954146/
分享到:
相关推荐
论文研究-基于资源重置的企业并购效率综合评价的非参数方法.pdf, 在对企业并购问题进行定量描述的基础上,给出了并购单元有效性的概念和判定方法,分析了其经济含义,探讨...
个人收集的10种方法,每一种都写的非常的详细,还带了例子。今天就分享给大家
学习mongodb,Studio 3T的试用日期的重置,之前在网上找到的都是不好用,这个在Studio3-2019.3.0之前版本测试过,可以使用!
此工具用于重置Studio 3T的试用日期,每次过期时运行此bat文件即可重新获取30天试用
富士施乐 P118W 重置硒鼓计数方法
点击重置按钮,提示是否确认重置表单
GoPro Hero3+ 银狗 最终固件,忘记WIFI密码的时候,可修改WiFi密码后刷机重置,修改settings.in文档里的无线网名称和密码即可,记住不支持中文。
mysql重置数据库密码
本文主要介绍了vmware Esxi 5.0 忘记密码重置的方法,分享给大家,具体如下: ...3. cp /mnt/sda5/stage.tgz /tmp/. 4. cd /tmp tar xvfz stage.tgz tar xvfz local.tgz 5. vi /tmp/etc/passwd 把类似root:x:1
银色狗3 如果你忘记了wifi密码,不能连接手机了,就使用这个工具 重新设置WiFi密码。 WiFi密码可以任意设置,操作简单。
由于长时间不通过账号密码的方式登录zabbix,容易忘记密码,小编今天通过转换对应的md5直接在数据库中重置密码,对重置Zabbix密码感兴趣的朋友一起看看吧
Linux根用户密码忘记重置方法
navicat16重置试用时间脚本,可重置navacat premium 16 的使用时间,重置一此可用半个月。
二手车评估方法重置成本法详解.pdf
重置测试
试用期重置方法 大致有手工笨法清理 和 全自动脚本清理两种 笨法也可以有两种 一种是在本机原系统上操作,先卸载 再清理残留的文件和注册表信息。 软件卸载会清理绝大部分信息,但是为了记住用户使用时间,肯定得...
Discuz! X3找回重置管理员密码的方法.docx
网络游戏-在网络测量中检测时钟重置的方法.zip
魔兽 重置副本 方法
二手车评估方法重置成本法详解.docx