Revision f6a00aa1 qemu-img.c

b/qemu-img.c
496 496
    return 0;
497 497
}
498 498

  
499
/*
500
 * Checks whether the sector is not a zero sector.
501
 *
502
 * Attention! The len must be a multiple of 4 * sizeof(long) due to
503
 * restriction of optimizations in this function.
504
 */
499 505
static int is_not_zero(const uint8_t *sector, int len)
500 506
{
507
    /*
508
     * Use long as the biggest available internal data type that fits into the
509
     * CPU register and unroll the loop to smooth out the effect of memory
510
     * latency.
511
     */
512

  
501 513
    int i;
502
    len >>= 2;
503
    for(i = 0;i < len; i++) {
504
        if (((uint32_t *)sector)[i] != 0)
514
    long d0, d1, d2, d3;
515
    const long * const data = (const long *) sector;
516

  
517
    len /= sizeof(long);
518

  
519
    for(i = 0; i < len; i += 4) {
520
        d0 = data[i + 0];
521
        d1 = data[i + 1];
522
        d2 = data[i + 2];
523
        d3 = data[i + 3];
524

  
525
        if (d0 || d1 || d2 || d3) {
505 526
            return 1;
527
        }
506 528
    }
529

  
507 530
    return 0;
508 531
}
509 532

  

Also available in: Unified diff