Alex: code optimization

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
User avatar
guru_florida
Posts: 45
Joined: Sat Mar 26, 2011 4:51 am

Alex: code optimization

Post by guru_florida »

Hi Alex,

I think we can use shifting here to eliminate a few multiplies... yes?

Line 1765:
rcOptions = (rcData[AUX1]<1300) + (1300<rcData[AUX1] && rcData[AUX1]<1700)*2 + (rcData[AUX1]>1700)*4
+(rcData[AUX2]<1300)*8 + (1300<rcData[AUX2] && rcData[AUX2]<1700)*16 + (rcData[AUX2]>1700)*32;

User avatar
ciskje
Posts: 34
Joined: Sat Mar 26, 2011 12:24 am

Re: Alex: code optimization

Post by ciskje »

GCC do this automatically.

User avatar
guru_florida
Posts: 45
Joined: Sat Mar 26, 2011 4:51 am

Re: Alex: code optimization

Post by guru_florida »

Really, cool! :) I didnt know it had that optimization. I assume then that arduino compiles with full -O.

User avatar
ciskje
Posts: 34
Joined: Sat Mar 26, 2011 12:24 am

Re: Alex: code optimization

Post by ciskje »

Arduino (sigh) compile with -Os (for size), but you can modify it to compile with -O2

Post Reply