[Jifty-commit] r4128 - in jifty/trunk: lib/Jifty lib/Jifty/Module
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Mon Sep 17 22:23:10 EDT 2007
Author: jesse
Date: Mon Sep 17 22:23:05 2007
New Revision: 4128
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Module/Pluggable.pm
jifty/trunk/lib/Jifty/Util.pm
Log:
r67338 at pinglin: jesse | 2007-09-17 22:19:33 -0400
* Use much less UNIVERSAL::require (to shave a second or two off start times)
Modified: jifty/trunk/lib/Jifty/Module/Pluggable.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Module/Pluggable.pm (original)
+++ jifty/trunk/lib/Jifty/Module/Pluggable.pm Mon Sep 17 22:23:05 2007
@@ -52,18 +52,9 @@
# On success, it expects you to return undef.
return if $module =~/\.#/;
-
- local $UNIVERSAL::require::ERROR;
-
- no warnings; # This is lexical and turns off exactly one warning below -- "Can't locate package in @ISA".
- # (for some reason, "no warnings 'syntax'" does not work as advertised here.)
- # Note that it does _not_ turn off warnings triggered in the $module itself.
- if ((not $module->require()) && ( $UNIVERSAL::require::ERROR !~ /^Can't locate/)) {
- die $UNIVERSAL::require::ERROR;
- }
- # We'd prefer to use Jifty::Util->require() here, but it spews crazy warnings
-
- return $UNIVERSAL::require::ERROR;
+ eval { Jifty::Util->require($module); };
+ my $err = $@;
+ return $err;
}
1;
Modified: jifty/trunk/lib/Jifty/Util.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Util.pm (original)
+++ jifty/trunk/lib/Jifty/Util.pm Mon Sep 17 22:23:05 2007
@@ -237,18 +237,19 @@
return 1 if $self->already_required($class);
- local $UNIVERSAL::require::ERROR = '';
- my $retval = $class->require;
- if ($UNIVERSAL::require::ERROR) {
- my $error = $UNIVERSAL::require::ERROR;
- $error =~ s/ at .*?\n$//;
- if ($args{'quiet'} and $error =~ /^Can't locate/) {
+ my $pkg = $class .".pm";
+ $pkg =~ s/::/\//g;
+ my $retval = eval {CORE::require "$pkg"} ;
+ my $error = $@;
+ if (my $message = $error) {
+ $message =~ s/ at .*?\n$//;
+ if ($args{'quiet'} and $message =~ /^Can't locate/) {
return 0;
}
- elsif ( $UNIVERSAL::require::ERROR !~ /^Can't locate/) {
- die $UNIVERSAL::require::ERROR;
+ elsif ( $error !~ /^Can't locate/) {
+ die $error;
} else {
- Jifty->log->error(sprintf("$error at %s line %d\n", (caller(1))[1,2]));
+ Jifty->log->error(sprintf("$message at %s line %d\n", (caller(1))[1,2]));
return 0;
}
}
More information about the Jifty-commit
mailing list