We can see the performance difference from the simple functions in Tango and Phobos
Walter Bright
newshound1 at digitalmars.com
Thu Jul 30 19:29:42 PDT 2009
zsxxsz wrote:
> Hi, below are the functions from Phobos and Tango with the same use, we can
> see why so many people like Tango more than Phobos.
>
>>>> In Phobos:
>
> string encode(string s)
> {
> // The ifs are (temprarily, we hope) necessary, because
> // std.string.write.replace
> // does not do copy-on-write, but instead copies always.
>
> if (s.indexOf('&') != -1) s = replace(s,"&","&");
> if (s.indexOf('"') != -1) s = replace(s,"\"",""");
> if (s.indexOf("'") != -1) s = replace(s,"'","'");
> if (s.indexOf('<') != -1) s = replace(s,"<","<");
> if (s.indexOf('>') != -1) s = replace(s,">",">");
> return s;
> }
That's from std.xml. I won't make any excuse for it, it's very inefficient.
More information about the Digitalmars-d
mailing list