[haiku-development] Re: [GSoC 2010] Services Kit API draft

  • From: Fredrik Holmqvist <fredrik.holmqvist@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 14 Apr 2010 21:40:16 +0200

2010/4/14 Christophe Huriaux <c.huriaux@xxxxxxxxx>:
>  *  As this is still a rough draft, I didn't put the overloaded
> members. But, is this really useful to handle BString parameters since
> BString::String() return the const char* version of the string ?

char * is actually pretty inefficient since it doesn't cache the
length of the string.
Consider concatenating two char * strings. You'll need:
* Iterate over both strings to find length
* malloc a new one with the new length
* memcopy both strings,

BString is more efficient since it can avoid the first step and, it's
internal storage can use tricks like copy on write.
char * should be avoided and it's usage shouldn't be promoted IMHO.

/Fredrik Holmqvist, TQH

Other related posts: