I have a huge list of objects (e.g. I call them messages). Every message contains an array (e.g. I name them user) with 2, 3 or 4 strings (userids).
If I loop trough all messages I want to check in every message whence a userid is in the array or not. At which count of items in the array it would be faster to use an associative array² instead of a normal array¹ (regardless the time for creating the associative array)?
Certainly it takes time to create a hash (I think the associative array uses it), so I think an array with two items will be faster to loop...
Here is example one:
messages: {
name: "msg1"
users:[
"1256",
"1456"
]
}
Here is example two:
messages: {
name: "msg1"
users:{
"1256": true,
"1456": true
}
}