[haiku-development] Re: BString method SymbolAt() proposal

  • From: Reinhard Scharnagl <ReScharn@xxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 19 Jun 2010 15:38:05 +0200

Am 19.06.2010 um 14:39 schrieb Rene Gollent:

> On Sat, Jun 19, 2010 at 8:18 AM, Reinhard Scharnagl <ReScharn@xxxxxxx> wrote:
>> Maybe I have been misunderstood. The routine should not cut the to be found
>> i-th symbol, but the symbol at index i.
> 
> This is precisely what everyone else is talking about. The problem is
> that BString is totally ignorant of the unicode characters internally,
> and as a consequence, your hypothetical SymbolAt(i) would have to loop
> through as much of the string as is needed to find the i'th character.
> Thus, doing so for an entire string like the code snippet you pasted
> would have extremely poor performance, as Ingo pointed out, and that's
> completely ignoring the overhead of having to construct all those
> extra BString objects to return the symbols.

Just the opposite is true. SymbolAt(i) should NOT iterate but access directly.

> A more unicode-aware
> string that uses wchar_t internally is definitely a far better
> solution here.

Sure. But I do not talk about a unicode solution, which is better, when
implemented correctly, but here I made a suggestion for BString only.

And I wonder how the current compiler will handle:

wchar_t euro = '€';

and simultaneously still support BString and multibyte message ids.

Reinhard (Octopus)

Other related posts: