rust-embedded-community / ssd1306

SSD1306 OLED driver
Apache License 2.0
301 stars 68 forks source link

Use iterators in interface send methods #106

Closed jamwaffles closed 4 years ago

jamwaffles commented 4 years ago

Hi! Thank you for helping out with SSD1306 development! Please:

PR description

Switches some for loops for iterators to speed up sends (and hopefully reduce code size) by eliding bounds checks.

jamwaffles commented 4 years ago

I just added some optimisations in 6ff90ff2abcb172db11e0d4540f8c2fcf70a4349 which should make set_pixel calls a lot faster. Unsure how to bench, but for one thing the change from an if/else to bit manip ops to set the pixel value in a byte should be much faster now. The generated assembly says so.

jamwaffles commented 4 years ago

Yeah, slightly bigger but maybe faster so worth it in the end? I dunno tbh, it's all tradeoffs lol. Thanks for the review!