note
japhy
I am very frustrated in that your patch looks simpler than
my attempt, and yet I'm not sure I understand, probably
because the <tt>AvMAX()</tt> and <tt>AvFILLp()</tt> don't
seem to be documented well enough for me to figure out what
they're doing.
<code>
if (num) {
i = AvFILLp(av);
/* Create extra elements */
/**/ slide = i > 0 ? i : 0;
/**/ num += slide;
av_extend(av, i + num);
AvFILLp(av) += num;
ary = AvARRAY(av);
Move(ary, ary + num, i + 1, SV*);
do {
ary[--num] = &PL_sv_undef;
} while (num);
/* Make extra elements into a buffer */
/**/ AvMAX(av) -= slide;
/**/ AvFILLp(av) -= slide;
SvPVX(av) = (char*)(AvARRAY(av) + slide);
}
}
</code>
Why do you add <tt>num</tt> to <tt>AvFILLp()</tt> (which is
the original <tt>num</tt> with <tt>slide</tt> added to it)
only to then SUBTRACT <tt>slide</tt>? And what <i>is</i>
<tt>AvMAX()</tt>?!
<br><br>
And I would personally suggest using the heuristic for slide
that I had in my code -- namely:
<code>
slide = (i < num && i > 0) ? i : num;
</code>
Anyway. Sigh. I'm not annoyed at you, but at my inability
to patch something that shouldn't have been such a well of
annoyance.
<br><br>
<tt><font color="#0000ff">japhy</font></tt> --
<a href="/index.pl?node=japhy&lastnode_id=3333">Perl and Regex Hacker</a>
42912
42912