unsigned int for indices

Help
2011-08-03
2013-03-06
  • Richard Falk

    Richard Falk - 2011-08-03

    Tip 10 in "Tips and trick for efficient programming" says "Use unsigned int for indices - the compiler will snip _lots_ of code."  By "indices" does this mean loop indices as in "for (i=0 ; i < limit ; i++)"?  Or does it mean array indices as in "array_"?  Or both?  Is there any further explanation as to why the unsigned int is better (i.e. why less code is generated)?_

     
  • Richard Falk

    Richard Falk - 2011-08-03

    The array brackets and "i" index got interpreted as an italics code.  It should read "array\" unless that too gets misinterpreted (I'm not sure of the escape sequence to disable BBCode interpretation).

     
  • Peter A. Bigot

    Peter A. Bigot - 2011-08-03

    Most of the legacy mspgcc documentation is out of date.  It isn't obvious to me why that advice would be relevant, now or in the past.  My general feeling is that you should write code that is easy to understand, and let the compiler figure out how to make it fast.  It can almost always do a better job than you can.

     
  • Richard Falk

    Richard Falk - 2011-08-14

    Thanks.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks