On Thursday, 28 February 2013 at 07:22:53 UTC, Walter Bright wrote:
On 2/27/2013 10:02 PM, deadalnix wrote:
On Thursday, 28 February 2013 at 05:28:47 UTC, Walter Bright wrote:
On 2/27/2013 9:20 PM, deadalnix wrote:
If the range define empty with something like front == sentinel, the inliner should kick in a reduce the whole stuff to only one read, no ?

   auto c = front;
   if (c == sentinel || c == XX)

is two reads. This may not seem important, but when you want high speed, it
can halve it.

Don't you have to check for both all the time ? You have to check for the
sentinel anyway.

I suggest again taking a look at the dmd source lexer.c for how to do it. There is no extra check.

I did, in fact I know it for quite a while.

It does check for sentinel in many places (and it has to). How is it better than a empty property defined as front == sentinel ?

For instance,

if(!r.empty) {
   switch(r.front) {
       // cases
   }

   // somecode
} else {
    // error code
}

Will be optimized by adding a case for the sentinel in the switch (if dmd don't, then it has to be fixed, LLVM is definitively able to do stuff like that, and I didn't checked, but I'd bet that GCC can do it as well) in the given way :

switch(r.front) {
    case sentinel :
       // error code
       goto Label;

    // cases
}

// somecode

Label:

I don't see how defining a specific sentinel range here helps.

Reply via email to