std.xml should just go
Jonathan M Davis
jmdavisProg at gmx.com
Thu Feb 3 23:34:39 PST 2011
On Thursday 03 February 2011 23:17:10 Max Samukha wrote:
> On 02/04/2011 05:07 AM, Walter Bright wrote:
> > Jonathan M Davis wrote:
> >> I only brought up Tango in the first place to point out that it is a
> >> goal of the new std.xml to at least come close to Tango's performance
> >> in parsing XML, because Tango's XML parser is very fast.
> >
> > The way to get a high performance string parser in D is to take
> > advantage of one of D's unique features - slices. Java, C++, C#, etc.,
> > all rely on copying strings. With D you can just use slices into the
> > original XML source text. If you're copying the text, you're doing it
> > wrong.
>
> .NET and Qt do have slices of some kind:
>
> http://msdn.microsoft.com/en-us/library/1hsbd92d.aspx
> http://doc.qt.nokia.com/latest/qstringref.html#details
>
> I am not sure whether their XML libraries use those.
Interesting. Slices are a rarity in C-based languages. In fact, I'd never even
heard of them before I started learning D. But now it drives me nuts to not have
them in C++. If I have to do much more string processing at work, I'll probably
write a StringSlice class or something similar to wrap strings in just so I
don't go insane.
In any case, if you're not used to using slices, I'm not sure that it's the kind
of thing that your average programmer is even going to think of, so it wouldn't
surprise me at all if their XML libraries don't use their slicing constructs -
though perhaps they do. It definitely helps that slices are built into D though.
We really don't have a good excuse _not_ to use them in std.xml.
Slices: just one more reason why D's arrays kick the pants of other languages'
arrays...
- Jonathan M Davis
More information about the Digitalmars-d
mailing list