Duff装置

 1 //credit: Speed Up Your Site (New Riders, 2003)

 2 var iterations = Math.floor(value.length / 8);

 3 var leftover = value.length % 8;

 4 var i = 0;

 5 

 6 if (leftover > 0) {

 7     do {

 8         process(values[i++]);

 9     } while (--leftover > 0);

10 }

11 do {

12     process(value[i++]);

13     process(value[i++]);

14     process(value[i++]);

15     process(value[i++]);

16     process(value[i++]);

17     process(value[i++]);

18     process(value[i++]);

19     process(value[i++]);

20 } while (--iterations > 0);

你可能感兴趣的:(du)