optimize dupe string impl to use less memory