In the get_integer_keyed_int method in perlarray.pmc, we're cuurently
 doing:

      INTVAL get_integer_keyed_int (INTVAL key) {
        if (key >= DYNSELF.elements() || key < -DYNSELF.elements()) {
            PMC* temp = undef(INTERP);
            return VTABLE_get_integer(INTERP, temp);
        }
        else
            return SUPER(key);
    }

 (with similar code for get_number_keyed_int and get_string_keyed_int).

 In other words, if we're referencing an element outside the current
 array bounds, then we call undef(), which creates a new PerlUndef PMC,
 and we then use this _solely_ to call get_integer on, despite the fact
 that we _know_ that the result is going to be zero. This seems
 remarkably inefficient. Is there any good reason not to simply rewrite
 the above as:

      INTVAL get_integer_keyed_int (INTVAL key) {
        if (key >= DYNSELF.elements() || key < -DYNSELF.elements()) {
            return 0;
        }
        else
            return SUPER(key);
    }


 --
 Simon




Reply via email to