[Issue 6528] Private module functions optimizations

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 20 01:14:35 PDT 2011


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



--- Comment #1 from bearophile_hugs at eml.cc 2011-08-20 01:14:33 PDT ---
Another optimization example:

private void foo(int[] a) {}
void main() {
    int[100] array;
    foo(array);
}


Converted to:

private void foo(ref int[100] a) {}
void main() {
    int[100] array;
    foo(array);
}

------------------

The optimization is possible if foo has more than one call from the module, if
the body of foo is short:

private void foo(int[] a) {
    // this is a short function
}
void main() {
    int[100] array1;
    foo(array1);
    int[200] array2;
    foo(array2);
}


Converted to:

private void foo(size_t N)(ref int[N] a) {
    // this is a short function
}
void main() {
    int[100] array1;
    foo(array1);
    int[200] array2;
    foo(array2);
}

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


More information about the Digitalmars-d-bugs mailing list