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.