On 07/11/2015 01:07, Marvin Humphrey wrote:
On Fri, Nov 6, 2015 at 4:32 AM, Nick Wellnhofer <[email protected]> wrote:
I'm wondering whether we should restrict CharBuf to string building and
rename it to something like StringBuilder. This would allow to remove a
couple of methods. For resizable buffers, users could switch to ByteBuf,
maybe with additional convenience methods to get Strings in and out of
ByteBufs.

Any time there's an opportunity to destroy code, my ears prick up. :)  The
code in CharBuf certainly gets a lot of use for things like like Str_newf(),
which is the StringBuilder case.  So then the question is what would
replace the performance-sensitive buffer case described above?

As I said, I'd replace CharBuf with ByteBuf. The following additions to ByteBuf should make this change trivial:

- Add BB_new_from_str.
- Make BB_Mimic also work with Strings.
- Add something like BB_Utf8_To_String, maybe with two versions
  for trusted and untrusted UTF-8.

Then we could remove:

- CB_new_from_str
- CB_new_from_utf8
- CB_new_from_trusted_utf8
- CB_Mimic
- CB_Mimic_Utf8
- CB_Set_Size (something like CB_Clear might be useful, though)
- CB_Get_Ptr8 (maybe?)

I'd keep CB_Get_Size and CB_Grow so users can give a hint of the expected result string size.

Nick

Reply via email to