Skip to content

Commit

Permalink
Optimize the speed.
Browse files Browse the repository at this point in the history
See https://en.wikibooks.org/wiki/Optimizing_Code_for_Speed . There may have
been some refactorings too.
  • Loading branch information
shlomif committed Feb 1, 2025
1 parent e37deb3 commit 1c4c624
Showing 1 changed file with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,30 @@ my $const_attrs = [
];

my $CHECK_SET_ONLY_ONCE = 0;
foreach my $const_attr (@$const_attrs)
if ( not $CHECK_SET_ONLY_ONCE )
{
has $const_attr => (
is => 'rw',
(
$CHECK_SET_ONLY_ONCE
? (
trigger => sub {
my ( $self, $newval ) = @_;
die "self=$self const_attr=$const_attr"
if ( $self->{_CTR}->{$const_attr}++ );
return;
}
)
: ()
)
);
has [@$const_attrs] => ( is => 'rw', );
}
else
{
foreach my $const_attr (@$const_attrs)
{
has $const_attr => (
is => 'rw',
(
$CHECK_SET_ONLY_ONCE
? (
trigger => sub {
my ( $self, $newval ) = @_;
die "self=$self const_attr=$const_attr"
if ( $self->{_CTR}->{$const_attr}++ );
return;
}
)
: ()
)
);
}
}

# These attributes mutate during a solver's run.
Expand Down

0 comments on commit 1c4c624

Please sign in to comment.