On Aug-07, Simon Glover wrote: > 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); > }
"Warning: use of uninitialized value". Or whatever else accessing an undef triggers. I wasn't sure exactly what that would do, so I played it safe and went the slow but sure route to duplicating the effect. That was a long time ago. If we now know exactly what converting an undef into an int should do, then we can do the same thing. Or directly call undef.get_integer, or whatever.