我也提出问题

保留原著,并且问题被回答或审核通过时通知你:


为什么指定Vector对象的长度,运行速度更快?

每次Vector大小增加时,都将分配一个新的内存块。Vector的当前内容会复制到新内存块中。这种额外的分配和复制数据会降低性能。所以,尽量在创建Vector对象时,能将长度设为固定值就设为固定值。

- 作者:SWFAQ | http://swfaq.org/

收藏 & 推荐 & 分享

Post a Comment

Your email is never shared. Required fields are marked *

*
*

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word