[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: Class::Fields, a base/fields.pm rewrite



On Tue, Jan 04, 2000 at 12:46:43PM -0500, Ilya Zakharevich wrote:
> Michael G Schwern writes:
> > As far as efficiency goes, yes there is a slight drop off.  I've seen
> > that my changes cause base.pm to take longer to initally load and use
> > up about 100KB more memory, but the run-time is the same (which is to
> > say, negligible).  Of course, I haven't done any optimizations yet.
> 
> This is a lot for smaller modules than Tk.  Why not make base load
> fielded stuff only if needed?

Okay, I can do that.  I didn't want to since I have to bust a layer of
encapsulation, since I needed a routine from Class::Fields to figure
out if I needed to load Class::Fields.  ie.  Instead of saying:

use Class::Fields::Fuxor;
if( has_fields($base) ) {
        require Class::Fields::Inherit;
        # Inherit and stuff ...
}

I have to duplicate Class::Fields::Fuxor::has_fields inside base.pm:

sub has_fields {
        my($class) = shift;
        my $fglob;
        return $fglob = ${"$class\::"}{"FIELDS"} and *$fglob{HASH};
}

if( has_fields($base) ) {
        require Class::Fields::Inherit;
        # Inherit fields and stuff...
}

Which is okay, I suppose, since base.pm and Class::Fields are close
buddies.

That change should eliminate any performance changes between the
existing version and mine.  It'll be in the next version of
Class::Fields.

-- 

Michael G Schwern                                           schwern@pobox.com
                    http://www.pobox.com/~schwern
     /(?:(?:(1)[.-]?)?\(?(\d{3})\)?[.-]?)?(\d{3})[.-]?(\d{4})(x\d+)?/i


Follow-Ups from:
Ilya Zakharevich <ilya@math.ohio-state.edu>
References to:
Michael G Schwern <schwern@pobox.com>
Ilya Zakharevich <ilya@math.ohio-state.edu>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]