4 ms·
After reading this blog post, I had a question: why doesn't it take less than millisecond in Rust code? And the answer is that the author allocates a string for
by m1el 6y ago
After reading this blog post, I had a question: why doesn't it take less than millisecond in Rust code?
And the answer is that the author allocates a string for each character, and does more allocation by calling to_uppercase/to_lowercase.
There's a hundredfold improvement in speed by using char or u8 to iterate over a string.