-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This knocks 256 bytes off I2C support (text), so we can potentially enable it on G030. More savings are potentially available in this code, and we've got a lot of duplication across targets that means we can probably save space on other machines as well. The techniques applied here: 1. Find larger chunks of repeated code and factor them into a common routine (the i2c_args -> i2c_args_to_device transition) 2. Find duplicate checks for things like bounds or slicing and make them occur in only one place, reusing the result. (e.g. when slicing like buf[..n], we can assign the result to a variable and reuse it -- and we can combine this with the check by writing buf.get(..n).) 3. Find unhandled integer overflow cases and convert them to more graceful failures (currently, clients can trivially crash Hiffy by sending large integers for many parameters; this reduces their number) 4. Apply shared subexpression elimination to things like the frame pointer / base pointer calculation in the write routine. Previously they were computed separately, which didn't make it clear to the compiler that they're trivially related, causing it to generate excess checks. I've also applied a lot more 'ok_or' and '?' patterns to remove a lot of manual match statements on errors, under the theory that the size of the code on the page ought to more accurately reflect its importance/complexity in the domain (I2C). I think this change makes the actual sources of complexity more apparent.
- Loading branch information
Showing
2 changed files
with
53 additions
and
86 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters