snowkit / snow

A low level cross platform framework for Haxe. Mac, Windows, Linux, Android, iOS, WebGL.
http://snowkit.org/snow
MIT License
133 stars 35 forks source link

Fix snow.platform.web.utils.ByteArray resizing #68

Closed restorer closed 9 years ago

restorer commented 9 years ago

In my app ByteArray has very slow performance while reading big json file. I dig into this problem, and found that set_length calls _snowResizeBuffer at every writeByte. Illustration:

value allocated action
- 0 initial
1 1 up resize
2 2 up resize
3 4 up resize
4 4 -
5 8 up resize
6 6 down resize
7 12 up resize
8 8 down resize
9 16 up resize
10 10 down resize
... ... ... etc ...

My proposal is to do down resize if allocated are twice more than required value.

ruby0x1 commented 9 years ago

I might not have been properly clear in the dev log, but this class and everything associated with it is being deleted during alpha-2.0 in favour of newer code. Nice catch though!

http://snowkit.org/2015/03/01/snowkit-dev-log-1/