Are l.568-572 not equiv to 
++types[type];
?