[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Texmacs-dev] Efficiency of C++ switch-statements
From: |
Joris van der Hoeven |
Subject: |
Re: [Texmacs-dev] Efficiency of C++ switch-statements |
Date: |
Tue, 11 Nov 2003 09:46:43 +0100 (CET) |
> | Much more code
> | is executed in the map object. You have to remember that a switch
> | just does assembly compare instructions. No method calls are made
> | (which are expensive), also the cmp instruction is fairly atomic and
> | is not a CISC feature (on RISC also), so no microcode is used as is
> | the mul and div instructions which are not atomic.
This is true, I also prefer not to use a software hashtable
(also because I would have to fill out the entries anyway,
so why not use a real table in that case?).
However, it might be interesting for the compiler to create
a hashtable. The idea is that all cases are known beforehand,
so the compiler might *choose* an efficient hash function for
the particular purpose.
> But, a virtual function call may be cheaper than the series of
> compares and jumps. And in case the compiler would have used a branch
> table, again the virtual function call may be cheaper.
[...]
> compared to a virtual function call, a switch is simpler onnly in a
> very limited cases.
I still do not see how you want to use virtual functions here.
- Re: [Texmacs-dev] Efficiency of C++ switch-statements, (continued)
Re: [Texmacs-dev] Efficiency of C++ switch-statements, Dan Martens, 2003/11/10
Re: [Texmacs-dev] Efficiency of C++ switch-statements, Joris van der Hoeven, 2003/11/11
Re: [Texmacs-dev] Efficiency of C++ switch-statements, Dan Martens, 2003/11/11
Re: [Texmacs-dev] Efficiency of C++ switch-statements, Gabriel Dos Reis, 2003/11/11