change IOBuffer to use Memory internally (#53192)
An Array is often still allocated on output, but this gives the compiler
a chance to potentially elide that in certain cases.
For measurement, it seems about 10% faster as a string builder:
```
julia> @btime repr("hello\nworld"^10);
1.096 μs (10 allocations: 640 bytes) # master
973.000 ns (9 allocations: 608 bytes) # PR
994.000 ns (8 allocations: 576 bytes) # also PR, after Revise-ing Base.wrap
```