From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.36.236.3 with SMTP id g3mr2037032ith.32.1521083409691; Wed, 14 Mar 2018 20:10:09 -0700 (PDT) X-Received: by 10.157.3.237 with SMTP id f100mr362409otf.6.1521083409548; Wed, 14 Mar 2018 20:10:09 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!peer01.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!r195-v6no615136itc.0!news-out.google.com!h73-v6ni1312itb.0!nntp.google.com!e10-v6no615798itf.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 14 Mar 2018 20:10:09 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=47.185.233.194; posting-account=zwxLlwoAAAChLBU7oraRzNDnqQYkYbpo NNTP-Posting-Host: 47.185.233.194 References: <365d65ea-5f4b-4b6a-be9b-1bba146394ab@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <76eeca56-3246-49d2-baf3-0879741e7e12@googlegroups.com> Subject: Re: Ada case-statement From: "Dan'l Miller" Injection-Date: Thu, 15 Mar 2018 03:10:09 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Body-CRC: 1619036982 X-Received-Bytes: 2344 Xref: reader02.eternal-september.org comp.lang.ada:50983 Date: 2018-03-14T20:10:09-07:00 List-Id: On Wednesday, March 14, 2018 at 7:57:57 PM UTC-5, Robert Eachus wrote: > The compiler probably will convert to an if statement,=20 For dense case statements that utilize all or most of an enumerated type's = enumerated values, a jump table is the most likely on most processors to ac= hieve O(1) growth [instead of if-statement-based O(n) growth, where n is th= e quantity of enumerated values in an enumerated type]. https://stackoverflow.com/questions/39875452/assembly-jump-branch-lookup-ta= bles-instead-of-lots-of-cmp-je In IA-32, a jump table can be transliterated fairly directly from a case-st= atement over a dense utilization of an enumerated type. Indeed, if the qua= ntity of enumerated values in the enumerated type is small enough, a case s= tatement that sparsely utilizes only a relative few of the enumerated value= s also can be transliterated to a jump table, where the unmentioned enumera= ted values conflate to unhandled case. jmp [jump_table + si] jump_table: dw .F_1, .F_2, ...