Re: pseudo-specs for a String class

From: Adrian Chadd <adrian_at_freebsd.org>
Date: Wed, 27 Aug 2008 13:38:08 +0800

2008/8/27 Amos Jeffries <squid3_at_treenet.co.nz>:

> Not relevant in Squid-3. debugs() uses stream operator of String class which
> can do exactly whatever it wants to produce a sequence of bytes.

As long as it doesn't end up doing something like magically casting to
const char *
to get a NUL terminated C String, or if someone implements std::string
generation..

>> * iterating/parsing; which can be replaced by using the length
>> parameter in pointer arithmetic (you can toss the pointer arithmetic
>> too in like 99% of the cases; the parser is about where the possible
>> speed boosts from pointer arithmetic would even matter)
>
> Thats the kicker, who Henrik pointed out. It requires the pre-filled buffer
> being broken into String by the parser which will need some custom
> replacement for strtok() (actually faster, but more bug prone).

Its not all that difficult, honestly. Its just time-consuming. Since
I've been down this path before, I'm happy to do part of the gruntwork
to sort out all the evil C-string abuses of Squid-String when the time
comes.

>> In any case, I agree with the general model of:
>>
>> * Memory: some chunk of contiguous memory somewhere;
>> * MemoryRegion: some reference to { Memory, offset, length }
>> * String: a MemoryRegion and some routines to manipulate it
>>
>> Adrian
>
> True, BUT, BUT everything behind MemoryReagion is memory
> allocator/management business and should not be involved with String.
> Only the MemoryRegon API affects String.

:) Do you count MemoryRegion as region of some non-refcounted block of
directly allocated RAM, or do you have a ref-counted Memory which
MemoryRegion takes a reference + offset + length of? Thats how it
works in s27_adri and it works well elsewhere.

Adrian
Received on Wed Aug 27 2008 - 05:38:10 MDT

This archive was generated by hypermail 2.2.0 : Wed Aug 27 2008 - 12:00:06 MDT