Skip to content

Commit

Permalink
a few more small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 30, 2013
1 parent 089936f commit c6ddf11
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
5 changes: 1 addition & 4 deletions lib/Mojo/Base.pm
Expand Up @@ -14,7 +14,6 @@ use IO::Handle ();
sub import {
my $class = shift;
return unless my $flag = shift;
no strict 'refs';

# Base
if ($flag eq '-base') { $flag = $class }
Expand All @@ -31,6 +30,7 @@ sub import {
# ISA
if ($flag) {
my $caller = caller;
no strict 'refs';
push @{"${caller}::ISA"}, $flag;
*{"${caller}::has"} = sub { attr($caller, @_) };
}
Expand All @@ -54,7 +54,6 @@ sub attr {
Carp::croak 'Default has to be a code reference or constant value'
if ref $default && ref $default ne 'CODE';

# Compile attributes
for my $attr (@{ref $attrs eq 'ARRAY' ? $attrs : [$attrs]}) {
Carp::croak qq{Attribute "$attr" invalid} unless $attr =~ /^[a-zA-Z_]\w*$/;

Expand All @@ -81,8 +80,6 @@ sub attr {
# Footer (return invocant)
$code .= " \$_[0];\n}";

# We compile custom attribute code for speed
no strict 'refs';
warn "-- Attribute $attr in $class\n$code\n\n" if $ENV{MOJO_BASE_DEBUG};
Carp::croak "Mojo::Base error: $@" unless eval "$code;1";
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Message.pm
Expand Up @@ -28,7 +28,7 @@ sub body {
# Get
return $content->asset->slurp unless @_;

# Set raw content
# Set
$content->asset(Mojo::Asset::Memory->new->add_chunk(@_));

return $self;
Expand Down
5 changes: 1 addition & 4 deletions lib/Mojolicious/Lite.pm
Expand Up @@ -20,17 +20,14 @@ sub import {
my $caller = caller;
no strict 'refs';
push @{"${caller}::ISA"}, 'Mojo';
my $app = shift->new;

# Generate moniker based on filename
my $moniker = basename $ENV{MOJO_EXE};
$moniker =~ s/\.(?:pl|pm|t)$//i;
$app->moniker($moniker);
my $app = shift->new(moniker => $moniker);

# Initialize routes without namespaces
my $routes = $app->routes->namespaces([]);

# Default static and template class
$app->static->classes->[0] = $app->renderer->classes->[0] = $caller;

# The Mojolicious::Lite DSL
Expand Down

0 comments on commit c6ddf11

Please sign in to comment.