$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2019-11-11 09:27:54
On Sun, 10 Nov 2019 at 14:16, Phil Endecott via Boost
<boost_at_[hidden]> wrote:
>
> Specifically thinking about strings, there are numerous ways
> that it could be done. Starting with
Even for integers there are multiple ways it could be done.
It's up to the compiler to decide what is best.
> (3) character-by-character comparison using nested switches:
>
> switch (s[0]) {
> case 'a': switch (s[1]) {
> case 'a': switch (s[2]) {
> case 0: f(); break;
> }
> case 'b': switch (s[2]) {
> case 0: g(); break;
> }
> }
> case 'x': switch (s[1]) {
> case 'y': switch (s[2]) {
> case 0: h(); break;
> }
> }
> }
That is probably the "natural" implementation that one would expect.
> (5) hashing, and then checking:
>
> switch (hash(s)) {
> case "aa"HASH: if (s=="aa") f(); break;
> case "ab"HASH: if (s=="ab") g(); break;
> case "xy"HASH: if (s=="xy") h(); break;
> }
That code doesn't really need to check, if your hashes collide the
compiler will reject the code.