Just for interest, INPUT_PULLUP does it in the order: set-input-mode, set-pin-high:
} else if (mode == INPUT_PULLUP) {
uint8_t oldSREG = SREG;
cli();
*reg &= ~bit; // set to INPUT
*out |= bit; // output HIGH
SREG = oldSREG;
Comments added by me.