On Thursday, 6 July 2017 at 09:11:44 UTC, Ola Fosheim Grøstad wrote:
ubyte[256] data;

if  (data.length > 0) {
   ubyte i = 0;
   do {
        writeln(i);
    } while ((++i) != cast(ubyte)data.length);
}

Here is another version that will work ok on CPUs that can issue many instructions in parallel if there are no dependencies between them as you avoid an explicit comparison on the counter (zero tests tend be be free):

ubyte[N] data;

size_t _counter = data.length;

if( _counter !=0){
  ubyte i  = 0;
  do {
    writeln(i);
    i++;
  } while (--_counter);
}



Reply via email to