std.xml should just go
Steven Schveighoffer
schveiguy at yahoo.com
Fri Feb 4 13:07:43 PST 2011
On Fri, 04 Feb 2011 15:44:46 -0500, Jeff Nowakowski <jeff at dilacero.org>
wrote:
> On 02/03/2011 10:07 PM, Walter Bright wrote:
>>
>> 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.
>
> Java's substring() does not copy the text, at least in the official JDK
> implementation. Unfortunately, it doesn't specify this behavior as part
> of the String API.
Yes, but Java's strings are immutable. Typically a buffered I/O stream
has a mutable buffer used to read data. This necessitates a copy. At the
very least, you need to continue allocating more memory to hold all the
strings.
-Steve
More information about the Digitalmars-d
mailing list