Sponsoring The Perl Toolchain Summit 2025: Help make this important event another success Learn more

NAME

AutoXS::Accessor - Identify accessors and replace them with XS

SYNOPSIS

package MyClass;
use AutoXS plugins => 'Accessor';
# or load all installed optimizing plugins
use AutoXS ':all';
sub new {...}
sub get_foo { $_[0]->{foo} }
sub other_stuff {...}
# get_foo will be auto-replaced with XS and faster

DESCRIPTION

This is an example plugin module for the AutoXS module. It searches the user package (MyClass above) for read-only accessor methods of certain forms and replaces them with faster XS code.

RECOGNIZED ACCESSORS

Note that whitespace, a trailing semicolon, and the method names don't matter. Also please realize that this is not a source filter.

sub get_acc { $_[0]->{acc} }
sub get_bcc {
my $self = shift;
$self->{bcc}
}
sub get_ccc {
my $self = shift;
return $self->{ccc};
}
sub get_dcc { return $_[0]->{dcc} }
sub get_ecc { shift->{ecc} }
sub get_fcc {
my ($self) = @_;
$self->{fcc}
}
sub get_gcc {
my ($self) = @_;
return $self->{gcc};
}
sub get_icc {
my ($self) = shift;
$self->{icc}
}
sub get_jcc {
my ($self) = shift;
return $self->{jcc};
}

SEE ALSO

AutoXS

Class::XSAccessor

AUTHOR

Steffen Mueller, <smueller@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2008 by Steffen Mueller

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8 or, at your option, any later version of Perl 5 you may have available.