You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2004/03/11 04:28:17 UTC
svn commit: rev 9346 - incubator/spamassassin/trunk/lib/Mail/SpamAssassin
Author: felicity
Date: Wed Mar 10 19:28:15 2004
New Revision: 9346
Modified:
incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm
incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore.pm
incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStoreDBM.pm
incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStoreSQL.pm
Log:
tokenize_line was making lots of subroutine calls to get_magic_re in its tight loop of token checking. let's just make the call once and cache it.
Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm (original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm Wed Mar 10 19:28:15 2004
@@ -363,11 +363,19 @@
}
}
+ # cache the magic token regexp...
+ my $magic_re = $self->{store}->get_magic_re();
+
foreach my $token (split) {
$token =~ s/^[-'"\.,]+//; # trim non-alphanum chars at start or end
$token =~ s/[-'"\.,]+$//; # so we don't get loads of '"foo' tokens
- next if ( $self->{store}->is_magic_token($token) ); # skip false magic tokens
+ # Skip false magic tokens
+ # TVD: we need to do a defined() check since SQL doesn't have magic
+ # tokens, so the SQL BayesStore returns undef. I really want a way
+ # of optimizing that out, but I haven't come up with anything yet.
+ #
+ next if ( defined $magic_re && /$magic_re/ );
# *do* keep 3-byte tokens; there's some solid signs in there
my $len = length($token);
Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore.pm (original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore.pm Wed Mar 10 19:28:15 2004
@@ -685,18 +685,17 @@
die "touches_cleanup: not implemented\n";
}
-=head2 is_magic_token
+=head2 get_magic_re
-public instance (Boolean) is_magic_token (string $token)
+public instance get_magic_re (String)
Description:
-This method determines if a given token is "magic" or special to the
-implementation.
+This method returns a regexp which indicates a magic token.
=cut
-sub is_magic_token {
- my ($self, $token) = @_;
+sub get_magic_re {
+ my ($self) = @_;
die "is_magic_token: not implemented\n";
}
Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStoreDBM.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStoreDBM.pm (original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStoreDBM.pm Wed Mar 10 19:28:15 2004
@@ -919,14 +919,6 @@
return qr/^\*\*[A-Z]+$/;
}
-sub is_magic_token {
- my ($self, $token) = @_;
-
- my $magic_re = $self->get_magic_re($self->{db_version});
-
- return ($token =~ /$magic_re/);
-}
-
# provide a more generalized public insterface into the journal sync
sub sync {
Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStoreSQL.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStoreSQL.pm (original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStoreSQL.pm Wed Mar 10 19:28:15 2004
@@ -892,20 +892,13 @@
return 1;
}
-=head2 is_magic_token
-
-public instance (Boolean) is_magic_token (string $token)
-
-Description:
-This method determines if a given token is "magic" or special to the
-implementation.
+=head2 get_magic_re
=cut
-sub is_magic_token {
- my ($self, $token) = @_;
-
- return 0; # nothing is magic
+sub get_magic_re {
+ my ($self) = @_;
+ undef;
}
=head2 sync