Issue #75 new
Alexander Pruss
created an issue

I found one can speed up 8-bit performance in the special case that the data pins are all arranged in the correct order on a single port.

Checking for this special case in LiquidCrystal.cpp and using it results in an approximately doubling of the speed.

Check for special case in LiquidCrystal:init() for the 8-bit case:

   volatile uint8_t* port = portOutputRegister(digitalPinToPort(d0));

   for (i=0; i<8; i++) {
       if (portOutputRegister(digitalPinToPort(_data_pins[i])) != port)
       if (digitalPinToBitMask(_data_pins[i]) != 1<<i)

   if (i==8)
       _data_port = port;
       _data_port = NULL;

And then act on it in writeNbits():

   if (_data_port != NULL && numBits == 8) {
       *_data_port = value;
       delayMicroseconds(12);  // 9 seems sufficient
   else {
       for (uint8_t i = 0; i < numBits; i++) 
          digitalWrite(_data_pins[i], (value >> i) & 0x01);

I found empirically that I did need to add a delay to compensate for the increased speed, but even with the delay it was worth it.