In general, what you're doing makes sense to me, assuming we get a non-negligable speed-up. However, there's a ton of repeated code  -- that same if/resize/getstring/assign thing happens about seven times. Can it be replaced by a function call for readability/maintainability?