How to remove all characters from a string, except the integers?
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Mar 4 20:33:08 UTC 2022
On Fri, Mar 04, 2022 at 07:51:44PM +0000, matheus via Digitalmars-d-learn wrote:
[...]
> for(j=0;j<1_000_000;++j){
> s="";
> s = str.filter!(ch => ch.isDigit).to!string;
This line allocates a new string for every single loop iteration. This
is generally not something you want to do in an inner loop. :-)
> }
[...]
> Unless I did something wrong (If anything please tell). By the way on
> DMD was worse, it was like 5x slower in your version.
[...]
I don't pay any attention to DMD when I'm doing anything remotely
performance-related. Its optimizer is known to be suboptimal. :-P
T
--
Study gravitation, it's a field with a lot of potential.
More information about the Digitalmars-d-learn
mailing list