See http://en.wikipedia.org/wiki/Loop_unwinding

On Tuesday, June 19, 2012 9:21:06 PM UTC-7, Victor Surfer wrote:
>
> Hello,
> I found memcmp.c in bionic is like this:
>  
>  30 int memcmp(const void *s1, const void *s2, size_t n)
>  31 {
>  32     const unsigned char*  p1   = s1;
>  33     const unsigned char*  end1 = p1 + n;
>  34     const unsigned char*  p2   = s2;
>  35     int                   d = 0;
>  36 
>  37     for (;;) {
>  38         if (d || p1 >= end1) break;
>  39         d = (int)*p1++ - (int)*p2++;
>  40 
>  41         if (d || p1 >= end1) break;
>  42         d = (int)*p1++ - (int)*p2++;
>  43 
>  44         if (d || p1 >= end1) break;
>  45         d = (int)*p1++ - (int)*p2++;
>  46 
>  47         if (d || p1 >= end1) break;
>  48         d = (int)*p1++ - (int)*p2++;
>  49     }
>  50     return d;
>  51 }
>
>  
> In the for loop, the same logic repeats 4 times, why? Can it no repeat?
>  
> Thx,
> Victor
>
>

-- 
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting

Reply via email to