Right now, this function counts the array all over again whenever an element is added. But since the command pushBack exists, it can be refactored to be much more efficient:
private ["_players"];
//--- Search in allUnits, otherwise dead players are ignored
_players = [];
{
if (isplayer _x) then {_players pushBack _x;};
} foreach (allunits + alldead);
_players