mikaelpatel/Cosa — pull request #95 by SlashDevin (2014-01-15 02:46:27+00:00)
Title: PinChangeInterrupt refactor

This saved almost 100 bytes RAM (on the MEGA), eliminated 60 LOC, and (probably) decreased the amount of time spent in the ISRs. It should also be easier to add other processor types.

NB: Although I tried to break it up into several smaller commits, there were two additional parts to the last commit that were not mentioned in that comment:

1. Removed the extraneous `PinChangeInterrupt::` from inside static member `on_interrupt`. Also changed local `state` to `newState` to disambiguate it from member `state` and make its purpose more obvious.

2. Added short circuit `changed` test to the for loop. The short circuit will, on average, eliminate 4 for-loop iterations for the price of an extra zero test. Also, if the input has already changed a second time, the short circuit will eliminate all 8 iterations. This is common with a bouncy input.

Tested on Mega and ProMini.