the stringstream allocation is actually expensive - so no need to do it if the value happens to already be a string.  That is why it is repeated in each else if block.