For digitalWrite, I originally implemented the const case optimization as a giant if-else chain. In fact, Teensyduino still has that version for Teensy 2.0.
On the Arduino Developers Mail List, in early November 2009, David Mellis specifically asked me to re-implement it using trinary operators. The he asked if anyone would do it for Arduino Mega, and as you can see, I did just a week later, on November 17, 2009.
Why he wanted that style is still a mystery to me. For a brief time, this optimization was actually committed to svn (back before they and everyone else switched to git/github). But ultimately he took the change out. The reasoning stated was that it duplicated the pins to registers mapping. Apparently he felt that would be simply too much long-term maintenance for Arduino and 3rd parties using the Arduino core for clones and close derivatives that use Arduino's published code with little or no modification.
Inside Teensyduino's core library, the pin mapping is defined in only 1 place. But instead of numerical constants populating an array, it's #define symbols. That allows the const case and non-const case to both compile from the same pin mapping info. It also provided AVR-based abstractions that allowed code to port easily between AVR-based boards.
This too I tried to contribute on several occasions in the 2009-2010 era. When they came out to Arduino Mega, it seems certain they'd have to go with this approach, or something more flexible. But instead, nearly all development continued on Duemilanove and later Uno, without any extra work on hardware abstractions or expanding the Arduino API beyond such basic functions. As a result, today lots of stuff simply doesn't work on Arduino Mega, and even moreso for Arduino Due, and newer 3rd party boards like Intel Galileo have horrible compatibility.
The only non-Uno Arduino board that actually is highly compatible today is Arduino Leonardo, and irs derivatives Yun & Micro. When Leonardo came out in 2012, I had spent nearly 3 years porting every widely used Arduino library to the 32u4 chip, so the Arduino folks have enjoyed a world where nearly all widely used code already had #ifdef __Atmega32U4__ embedded, even in their official libraries like Servo, SoftwareSerial and Firmata. It was much, much easier to contribute code to ALL the widely used libraries than to get Arduino to accept just 1 contribution to make things cross-board compatible.
About a year ago, David Mellis stepped down as Arduino's software lead, replaced by Cristian Maglie. Cristian seems far more open to ideas and contributions. Had he been the software lead before I was working so heavily on Teensy 3.x, and many others were offering contributions, Arduino as a platform would have probably turned out quite a bit differently.
I've had far less time for Arduino contributions since about April 2012, when nearly all my development time shifted to ARM and Teensy3. I'm far behind where I wanted to be on the audio library, but steady progress is being made. I have some other big plans for the Teensy3 platform later this year, which are going to keep me really busy.
My hope is sometime in 2015 or 2016, Teensy 3.x will be a very mature platform and maybe I'll get a year or two to really work on a lot of Arduino contributions and other stuff that isn't basically starting it all over again on a new platform. The newest, latest and greatest hardware is sexy and it's what sells, but that not-to-glamorous work on software infrastructure and refining usability and thousands of tiny details so everything "just works" is what really makes for a first class experience when people build projects.
If only there were a LOT more hours in every day....