Optimize entity and addComponent function to create fewer objects

We should avoid creating objects that will be garbage collected,
because this slows downs performances and especially if you
create a lot of entities.
Merge pull request #809 from kevinsimper/avoid-creating-objects

Optimize entity and addComponent function to create fewer objects