# Quick Array Performance Question

**URL:** <https://forum.kirupa.com/t/quick-array-performance-question/265349>\
**Category:** flash\
**Created:** [July 7, 2008, 11:00pm UTC](https://forum.kirupa.com/t/quick-array-performance-question/265349 "2008-07-07T23:00:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DesignerMichael](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@DesignerMichael](https://forum.kirupa.com/u/DesignerMichael)\
**Post date:** [July 7, 2008, 11:00pm UTC](https://forum.kirupa.com/t/quick-array-performance-question/265349/1 "2008-07-07T23:00:53Z")

</div>

How much of a performance drain would this be? Here is a trace of my array:

trace(myArray); //My array  
Result: “,[object Object],[object Object]”

As you can see… There are only two objects in the array, at an index of around 40. Now imagine an array with two objects at an index of 600,000,000+ and running this code:

```auto

for (var i:int in myArray) {
   trace(myArray*.objectVar);
}

```

Would this be too slow?

I need to know if I need to change my array to not use ID’s, and instead use push and a search function.

---

<div class="post-metadata">

**Author:** ![DesignerMichael](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@DesignerMichael](https://forum.kirupa.com/u/DesignerMichael)\
**Post date:** [July 7, 2008, 11:44pm UTC](https://forum.kirupa.com/t/quick-array-performance-question/265349/2 "2008-07-07T23:44:45Z")

</div>

I added two functions to my code to make it more efficient.

I simply push player data objects onto an array, and search the objects in the array find the player data.

Much more efficient?

```auto

        function getPlayerData(Id):Object {
            var result:Object;
            for (var i:String in Players) {
                if (Players*.Id == Id) {
                    result = Players*;
                }
            }
            return result;
        }
        function getPlayerDataIndex(Id):int {
            var result:int;
            for (var i:String in Players) {
                if (Players*.Id == Id) {
                    result = int(i);
                }
            }
            return result;
        }

```
