texmacs-dev
[Top][All Lists]
Advanced

[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 01:04:00 +0100

Bob McElrath <address@hidden> writes:

| > Another question: if I do not put the cases in the same order
| > as the enumeration, does this alter the efficiency?
| 
| If I remember correctly, switch used to essentially be a <= so you had
| to make sure they were in order or the wrong case would be executed.  (I

That must be wrong.

| just tested this, and it is not true -- either I remember wrong or this
| is a C/C++ difference)  I don't know if this varies from compiler to
| compiler.

In C or C++, case-labels are tied to "break"s.

| Also consider using the STL hash_map object, which gives you O(1)

or virtual functions they might be as efficient as a table lookup.

| lookups and does not waste space when your table is sparse.

-- Gaby




reply via email to

[Prev in Thread] Current Thread [Next in Thread]