> those .replace() calls will allocate unnecessarily,
All the time or only in Rust or Lisp? I would guess the compiler can optimize it because it is an XValue.
All the time or only in Rust or Lisp? I would guess the compiler can optimize it because it is an XValue.
In theory the compiler could notice that the spaces added to the newly allocated strings are only used to influence the behavior of `split_whitespace` and do not otherwise affect the output of the function. In practice, it does not: https://rust.godbolt.org/z/z573Mvjzz The compiler does not decide to inline the call to `replace` and therefore does not do any special reasoning about it.