[haiku-commits] Re: haiku: hrev52551 - headers/os/codec src/kits/codec

  • From: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 19 Nov 2018 08:44:14 +0100

Am 18/11/2018 um 18:24 schrieb Dario Casalinuovo:

Someone may question why I'm using integral keys there. This is an interesting topic.

On some hand, having random strings without a fixed length is good for the user, as those are easily readable.
On the other hand it's not so good for the programmer and the compiler. C++ has strict limitations on how something like that can be declared as string.
Without C++11 it's even worse. On another side, BMessage uses strings as keys (is this good at all?), so any performance benefit is mitigated this way.
If the enums are contiguous and starting from 0 it is possible to add a O(c) function that converts it to a string, but not the inverse as the string still needs to be compared. IDv3 isn't that helpful as it uses unreadable strings. So, I am not convinced by any solution at this precise moment.

I didn't see this post yet, so you can probably disregard my earlier one.
Performance is only a concern if performance is a concern :-)
BMessages are obviously fast enough to be used as the base IPC class in Haiku which has *much* higher needs than a BMetaData class could ever have in any context I could think about (unless you plan to evaluate it in every sample).

Bye,
   Axel.

Other related posts: