Deutsch English Français Italiano |
<vg00gg$2mufa$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Richard Harnden <richard.nospam@gmail.invalid> Newsgroups: comp.lang.c Subject: Re: else ladders practice Date: Thu, 31 Oct 2024 13:25:36 +0000 Organization: A noiseless patient Spider Lines: 41 Message-ID: <vg00gg$2mufa$1@dont-email.me> References: <3deb64c5b0ee344acd9fbaea1002baf7302c1e8f@i2pn2.org> Reply-To: nospam.harnden@invalid.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 31 Oct 2024 14:25:37 +0100 (CET) Injection-Info: dont-email.me; posting-host="36b6b786433670b6c56ea842816f20dd"; logging-data="2849258"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188jdLMb/lwiQFZL0L9c8rRzlV20jCLM1w=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:31M72j7CNZ9G/aak+IidMtc5x4A= Content-Language: en-US In-Reply-To: <3deb64c5b0ee344acd9fbaea1002baf7302c1e8f@i2pn2.org> Bytes: 1897 On 31/10/2024 12:11, fir wrote: > somethins i got such pices of code like > > if(n==1) {/*something/} > if(n==2) {/*something/} > if(n==3) {/*something/} > if(n==4) {/*something/} > if(n==5) {/*something/} > > technically i would need to add elses - but the question is if to do that Why not ... switch (n) { case 1: /* something */ break; case 2: /* etc ... */ default: /* something else */ } .... ? > > do teh code has really chance to be slower without else (except some > very prmitive compilers) ?? > > not adding else makes liek code shorter.. so im not literally sure which > is better The size of teh [sic] source code won't make any difference to the size of the executable - so aim for readability first and foremost.