ason Gloudon <[EMAIL PROTECTED]> wrote:
> On Sat, Nov 17, 2001 at 02:22:44PM +0000, [EMAIL PROTECTED] wrote:
> > Alan Burlison <[EMAIL PROTECTED]> wrote:
> > > Dave Mitchell wrote:
> > > > * Is there ever any need to for a PMC type which holds both an int and
> > > > a
> > > > num? In the Perl 5 case we were constrained by code that expected to
> > > > always
> > > > find an int (or a num) in a fixed slot in the SV; with PMCs, all
> > > > access
> > > > to these slots is via methods, so an int-num or num-int conversion can
> > > > be done on the fly.
> 
> If you use the same value enough times in places where you need an integral
> value, (an array index, an argument to substr etc), it is faster to cache the
> int value than converting from double (or BIGFLOAT) every time.

The overhead of calling the 'get_int' method of a PMC will probably swamp
the float->int conversion time for most processors these days. And not
maintaining both values will probably avoid the need for allocating
an extra structure to hold the values, and/or the need for flags and
if (NoK) ... else if (IoK) .. else ...
style code.

Reply via email to