Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

switch implementation

0 views
Skip to first unread message

Yamin

unread,
Apr 17, 2003, 1:26:00 PM4/17/03
to
Hey all,

This is just a curiosity question. How is a switch implemented in
watcom? Is it in linear time or constant time?

I'm sure all kind of optimization is done, but my simple brain really
thinks of two ways of doing it.

linear: basically resolves down to a bunch of ifs
constant: a hash is done on the value, and then a 'goto' array is
used to jump to the correct 'case' label.

I suppose the effectiveness of either method is based on the number of
cases, how 'continuous' the cases are, and the 'hash' function.

Thanks for the enlightenment,

Yamin

0 new messages