[Oberon] CASE without ELSE
chris at cfbsoftware.com
Sat Feb 17 02:43:15 CET 2018
> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
> Andreas Pirklbauer
> Sent: Saturday, 17 February 2018 12:16 AM
> To: ETH Oberon and related systems
> Subject: [Oberon] CASE without ELSE
> PS: I believe this is the only place in the Oberon system where
> one would see a measurable performance gain (here 10%) speedup
> (correct me if I’m wrong)
It would take some time (more than I currently have!) to prove whether or not this is the case. I suspect that there is no other single CASE in PO2013 that would have the same impact but there are a few areas in the compiler where CASE statements could be reinstated and the cumulative improvements could be significant.
Ones that immediately stand out are ORP.StandFunc, ORP,StandProc and ORP.factor. Look for any procedure which has a collection of more than half-a-dozen ELSIFs that test a single value. Alternatively search for "CASE" in the original Project Oberon source code. There are about 30 instances including a couple of nested CASEs.
As spelt out in Arthur Sale's paper that Diego Sardina referred to, the impact of CASE has less effect if the probability of each branch occurring is wildly different. However, this assumes that programmers have bothered to think about which branches are likely to occur more frequently and shuffle their IF-ELSIFs so they are near the top. With the CASE statement you do not have to concern yourself with this sort of hand-optimisation and have more ability to make the source more concise and readable (e.g. order the cases alphabetically) or more closely aligned to the original real-world problem statement (e.g. my Soundex example) .
More information about the Oberon