[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Texmacs-dev] Efficiency of C++ switch-statements
From: |
Gabriel Dos Reis |
Subject: |
Re: [Texmacs-dev] Efficiency of C++ switch-statements |
Date: |
11 Nov 2003 16:51:14 +0100 |
[ I forgot to add the following in my reply ]
"Dan Martens" <address@hidden> writes:
| >Not always. The compiler (g++ or gcc) can use a table with entries or a
| >series of compares and jumps, that depends on the density of the labels.
| >See Message-ID: <address@hidden>
|
| Yes, this is true, but as Joris stated previously, his switch
| statement was sparse, with many "fall-throughs" to a single piece of
| code. This is what I experimented with. I apologize if I did not
| cover all the different implementations of a switch statement (of
| which there are many), but I was just answering the question at
| hand.
It is not clear to me that Joris' switch is sparse. I would expect
something like
switch (tag) {
<all different cases>
case similar1:
case similar2:
case similar3:
....
case similarN:
// common code ...
break;
default:
// should not happen
std::abort();
break;
};
which is not what I call a sparse switch-statement even if there are
about 140 fall-throughs.
-- Gaby