Re: problem using INTERFACE_BUFFER

[email protected] Mon, 23 Dec 2002 11:26:56 -0600
Newsgroups gmane.mail.eps
Organization Inter7 Internet Technologies, Inc.
Message-ID <[email protected]>
David Relson wrote:
> 
> At 12:09 PM 12/23/02, [email protected] wrote:
> > >
> > > In several places there are "if () elseif () elseif()..." sequences that
> > > can be nicely replaced by switches.  eps.c, content.c, and encode.c are
> > > places where I've done this.
> >
> >Well, the question here becomes (for me at least; since this is a parser
> >library),
> >which is going to be the most efficient, or is there no difference after
> >the compiler interprets the code?
> 
> Assuming sequential values (such as an enum generates by default), the
> switch statement will be a tad bit faster.  With the if statements, there
> are multiple "compare, branch" sequences.  Branching is bad for any sort of
> pipelined cpu.  With the switch statement, there's an initial bounds check
> and then a branch through a transfer vector.
> 
> The biggest effect is on readability because the structure of the switch
> and its case statements are obvious at a glance.  When I see
> if...else...if..else.., it is necessary to read every test since there is
> no homogeneity requirement.  With a switch, the conditional value is stated
> at the beginning and the values it compares against are all constants.  The
> statement can be scanned (rather than read).

I see.  Well, that makes more sense to me. :)
I will add that to me current TODO.  However, please be sure to make
note
of changes you want to EPS v1.4 (when I get the demo up), instead of 1.2
which
has significant changes made to it.

-- 
mailto:[email protected]
Matt Brookings - Chief Technical Officer
Inter7 Internet Technologies, Inc.
www.inter7.com - 847-492-0470
Prices at http://www.inter7.com/prices