Is there an advantage to set pinmodes via bitmask and register? I'm working with the capacitive sensor library currently and the author does not use digitalWrite(), but instead sets the output of a pin via functions changing the bitmasks of certain registers:

https://github.com/PaulStoffregen/CapacitiveSensor/blob/master/CapacitiveSensor.h#L39

I looked into the OneWire library description those functions come from, but I still can't see any advantage over simply using the standard way Arduino proposes.
Is there an advantage to set pinmodes via bitmask and register?


I can name a few:

1) speed - I benchmarked the arduino pin ops vs. direct register ops here;

2) size - the code size is considerably bigger with the arduino library;

3) portability - the bitmark approach is supported by any C-compiler;

4) convention - i'm used to the bitmask approach and wrote all of my libraries around it;
...

as i'm sure others have their reasons to use the bitmasks.