Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-unix!hplabs!nsc!nsta!instable!amos From: amos@instable.UUCP (Amos Shapir) Newsgroups: comp.lang.c Subject: Re: Long Branches Message-ID: <672@instable.UUCP> Date: Tue, 20-Jan-87 02:00:06 EST Article-I.D.: instable.672 Posted: Tue Jan 20 02:00:06 1987 Date-Received: Tue, 20-Jan-87 23:33:01 EST References: <3950006@nucsrl.UUCP> <6552@alice.uUCp> Reply-To: amos%nsta@nsc.com (Amos Shapir) Organization: National Semiconductor (Israel) Ltd. Lines: 14 A portable kludge solution to the problem: the VAX BSD compiler generates 'casel' instructions only for switches in which the value range is dense, i.e. there are a lot of used values between the highest and lowest case values (I think the criterion is (hi-lo)/nused>=1/3 ). Otherwise, it generates a set of if's, creating in effect a binary search tree. If you add a dummy case with a value that is way out of the range, if's should be created instead of a casel. After that, if the branches are still too long, just do 'sed s/brw/jmp/' on the assembly file. -- Amos Shapir National Semiconductor (Israel) 6 Maskit st. P.O.B. 3007, Herzlia 46104, Israel (011-972) 52-522261 amos%nsta@nsc 34.48'E 32.10'N