0

我将需要存储大量的 x/y 位置对。现在我不确定是否对这些使用 Flash geom.Point-class,因为性能对我的应用程序很重要,而且我不会使用任何 Point-class 的方法。所以我想知道性能是否会受益于我创建和使用只有 x 和 y 属性的自定义类,或者我是否也可以只使用 geom.Point 而不会降低性能?

或者换句话说:geom.Point 的许多方法(我不会调用)的纯粹存在是否会影响它的实例?

4

1 回答 1

0

It would most certainly be quicker creating a small class to store x and y values as the overhead from the Point class will have an effect on the speed of the program. By writing your own class you can also take advantage of writing your own functions to handle simple data manupulation (adding/subtracting/multiplying) rather than having to do x1 + x2 and y1 + y2.

For an example try making a blank project with nothing but a timer and a loop and time how long it takes to create 10 million (for example) Points and store them in an array, and how long it takes to create 10 million of your own class with only x and y member variables.

于 2013-04-23T14:24:08.370 回答