http://d.puremagic.com/issues/show_bug.cgi?id=4440


Brad Roberts <bra...@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|nob...@puremagic.com        |bra...@puremagic.com


--- Comment #2 from Brad Roberts <bra...@puremagic.com> 2010-07-11 10:13:14 PDT 
---
Reducing the test case further:
extern(C) int printf(const char*, ...);

bool if_delegate(int i, bool delegate(ref int) predicate)
{
    return predicate(i);
}

bool if_nodelegate(int i)
{
    return i == 99;
}

void main()
{
    foreach(i; 1 .. 100)
        if (if_delegate(i, (ref int j) { return j == 99; }))
            printf("i = %d\n", i);

    foreach(i; 1 .. 100)
        if (if_nodelegate(i))
            printf("i = %d\n", i);
}

In the previous version of the code, the use of the for loops makes the cost of
the functions too high for the inliner to bother inlining find_if into main. 
Also,in the non-inlined version of the function, there's no way for it to
inline the delegate since it's a variable, not a constant thing.

This changed version reduces the problem to: will it inline the delegate?  The
answer is still no, but allows that specific problem to be explored.

Leandro, does this stray too far away from the underlying code that led you to
file this bug?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to