Skip to content
Browse files

Make classes immutable. Mutable classes are a lot slower.

  • Loading branch information...
1 parent 5538554 commit 5bc706912d4072d64c3b64fdb63bdb0adffe6c47 @rcaputo committed Jun 3, 2012
Showing with 96 additions and 0 deletions.
  1. +2 −0 lib/Reflex/Acceptor.pm
  2. +2 −0 lib/Reflex/Base.pm
  3. +2 −0 lib/Reflex/Callback.pm
  4. +2 −0 lib/Reflex/Callback/CodeRef.pm
  5. +2 −0 lib/Reflex/Callback/Method.pm
  6. +2 −0 lib/Reflex/Callback/Promise.pm
  7. +2 −0 lib/Reflex/Callbacks.pm
  8. +2 −0 lib/Reflex/Client.pm
  9. +2 −0 lib/Reflex/Codec/Message.pm
  10. +2 −0 lib/Reflex/Codec/Message/Datagram.pm
  11. +2 −0 lib/Reflex/Codec/Message/Eof.pm
  12. +2 −0 lib/Reflex/Codec/Message/Stream.pm
  13. +2 −0 lib/Reflex/Collection.pm
  14. +2 −0 lib/Reflex/Connector.pm
  15. +2 −0 lib/Reflex/Decoder/Line.pm
  16. +2 −0 lib/Reflex/Eg.pm
  17. +2 −0 lib/Reflex/Eg/Inheritance/Moose.pm
  18. +2 −0 lib/Reflex/Eg/Inheritance/Plain.pm
  19. +2 −0 lib/Reflex/Encoder/Line.pm
  20. +2 −0 lib/Reflex/Event.pm
  21. +2 −0 lib/Reflex/Event/Datagram.pm
  22. +2 −0 lib/Reflex/Event/EOF.pm
  23. +2 −0 lib/Reflex/Event/Error.pm
  24. +2 −0 lib/Reflex/Event/FileHandle.pm
  25. +2 −0 lib/Reflex/Event/Flushed.pm
  26. +2 −0 lib/Reflex/Event/Interval.pm
  27. +2 −0 lib/Reflex/Event/Octets.pm
  28. +2 −0 lib/Reflex/Event/POE.pm
  29. +2 −0 lib/Reflex/Event/Postback.pm
  30. +2 −0 lib/Reflex/Event/SigChild.pm
  31. +2 −0 lib/Reflex/Event/Signal.pm
  32. +2 −0 lib/Reflex/Event/Socket.pm
  33. +2 −0 lib/Reflex/Event/Time.pm
  34. +2 −0 lib/Reflex/Event/Timeout.pm
  35. +2 −0 lib/Reflex/Event/ValueChange.pm
  36. +2 −0 lib/Reflex/Event/Wakeup.pm
  37. +2 −0 lib/Reflex/Filehandle.pm
  38. +2 −0 lib/Reflex/Interval.pm
  39. +2 −0 lib/Reflex/PID.pm
  40. +2 −0 lib/Reflex/POE/Event.pm
  41. +2 −0 lib/Reflex/POE/Session.pm
  42. +2 −0 lib/Reflex/POE/Wheel.pm
  43. +2 −0 lib/Reflex/POE/Wheel/Run.pm
  44. +2 −0 lib/Reflex/Signal.pm
  45. +2 −0 lib/Reflex/Stream.pm
  46. +2 −0 lib/Reflex/Timeout.pm
  47. +2 −0 lib/Reflex/UdpPeer.pm
  48. +2 −0 lib/Reflex/Wakeup.pm
View
2 lib/Reflex/Acceptor.pm
@@ -18,6 +18,8 @@ with 'Reflex::Role::Accepting' => {
method_stop => 'stop',
};
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Base.pm
@@ -7,6 +7,8 @@ with 'Reflex::Role::Reactive';
# Composes the Reflex::Role::Reactive into a class.
# Does nothing of its own.
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Callback.pm
@@ -10,6 +10,8 @@ has object => (
weak_ref => 1,
);
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Callback/CodeRef.pm
@@ -15,6 +15,8 @@ sub deliver {
$self->code_ref()->($self->object(), $event);
}
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Callback/Method.pm
@@ -16,6 +16,8 @@ sub deliver {
$self->object()->$method_name($event);
}
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Callback/Promise.pm
@@ -50,6 +50,8 @@ sub merge_into {
undef;
}
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Callbacks.pm
@@ -276,6 +276,8 @@ sub make_null_handler {
return $method_name;
}
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Client.pm
@@ -83,6 +83,8 @@ sub stop {
$self->stopped();
};
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Codec/Message.pm
@@ -13,4 +13,6 @@ has priority => (
default => 500,
);
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Codec/Message/Datagram.pm
@@ -10,4 +10,6 @@ has octets => (
default => '',
);
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Codec/Message/Eof.pm
@@ -4,4 +4,6 @@ package Reflex::Codec::Message::Eof;
use Moose;
extends 'Reflex::Codec::Message';
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Codec/Message/Stream.pm
@@ -19,4 +19,6 @@ has octets => (
},
);
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Collection.pm
@@ -89,6 +89,8 @@ sub has_many {
$meta->add_attribute($name, %etc);
}
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Connector.pm
@@ -18,6 +18,8 @@ with 'Reflex::Role::Connecting' => {
cb_error => make_emitter(on_error => "error"),
};
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Decoder/Line.pm
@@ -38,4 +38,6 @@ sub shift {
return Reflex::Codec::Message::Datagram->new(octets => $matches[0]);
}
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Eg.pm
@@ -1,5 +1,7 @@
package Reflex::Eg;
+__PACKAGE__->meta->make_immutable;
+
1;
=pod
View
2 lib/Reflex/Eg/Inheritance/Moose.pm
@@ -8,6 +8,8 @@ sub on_done {
print scalar(localtime()), " - Subclass got timeout.\n";
}
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Eg/Inheritance/Plain.pm
@@ -9,6 +9,8 @@ sub on_done {
print scalar(localtime()), " - Subclass got timeout.\n";
}
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Encoder/Line.pm
@@ -44,4 +44,6 @@ sub shift {
return $next;
}
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Event.pm
@@ -104,4 +104,6 @@ sub dump {
return $dump;
}
+__PACKAGE__->meta()->make_immutable();
+
1;
View
2 lib/Reflex/Event/Datagram.pm
@@ -18,4 +18,6 @@ has peer => (
required => 1,
);
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Event/EOF.pm
@@ -3,4 +3,6 @@ package Reflex::Event::EOF;
use Moose;
extends 'Reflex::Event';
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Event/Error.pm
@@ -33,4 +33,6 @@ has formatted => (
}
);
+__PACKAGE__->meta->make_immutable();
+
1;
View
2 lib/Reflex/Event/FileHandle.pm
@@ -9,4 +9,6 @@ has handle => (
required => 1,
);
+__PACKAGE__->meta->make_immutable();
+
1;
View
2 lib/Reflex/Event/Flushed.pm
@@ -3,4 +3,6 @@ package Reflex::Event::Flushed;
use Moose;
extends 'Reflex::Event';
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Event/Interval.pm
@@ -3,4 +3,6 @@ package Reflex::Event::Interval;
use Moose;
extends 'Reflex::Event::Time';
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Event/Octets.pm
@@ -9,4 +9,6 @@ has octets => (
required => 1,
);
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Event/POE.pm
@@ -13,4 +13,6 @@ has args => (
},
);
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Event/Postback.pm
@@ -15,4 +15,6 @@ has response => (
required => 1,
);
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Event/SigChild.pm
@@ -15,4 +15,6 @@ has exit => (
required => 1,
);
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Event/Signal.pm
@@ -9,4 +9,6 @@ has signal => (
required => 1,
);
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Event/Socket.pm
@@ -13,4 +13,6 @@ has peer => (
},
);
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Event/Time.pm
@@ -3,4 +3,6 @@ package Reflex::Event::Time;
use Moose;
extends 'Reflex::Event';
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Event/Timeout.pm
@@ -3,4 +3,6 @@ package Reflex::Event::Timeout;
use Moose;
extends 'Reflex::Event::Time';
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Event/ValueChange.pm
@@ -15,4 +15,6 @@ has new_value => (
required => 1,
);
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Event/Wakeup.pm
@@ -3,4 +3,6 @@ package Reflex::Event::Wakeup;
use Moose;
extends 'Reflex::Event::Time';
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Filehandle.pm
@@ -46,4 +46,6 @@ with 'Reflex::Role::Writable' => {
method_stop => 'stop_wr',
};
+__PACKAGE__->meta->make_immutable;
+
1;
View
2 lib/Reflex/Interval.pm
@@ -19,6 +19,8 @@ with 'Reflex::Role::Interval' => {
method_stop => "stop",
};
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/PID.pm
@@ -27,6 +27,8 @@ with 'Reflex::Role::PidCatcher' => {
method_resume => 'resume',
};
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/POE/Event.pm
@@ -50,6 +50,8 @@ sub deliver {
);
}
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/POE/Session.pm
@@ -45,6 +45,8 @@ sub deliver {
}
}
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/POE/Wheel.pm
@@ -95,6 +95,8 @@ sub deliver {
);
}
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/POE/Wheel/Run.pm
@@ -99,6 +99,8 @@ sub kill {
$self->wheel()->kill(@_);
}
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Signal.pm
@@ -27,6 +27,8 @@ with 'Reflex::Role::SigCatcher' => {
method_resume => 'resume',
};
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Stream.pm
@@ -18,6 +18,8 @@ with 'Reflex::Role::Streaming' => {
cb_closed => make_terminal_emitter(on_closed => "closed"),
};
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Timeout.pm
@@ -17,6 +17,8 @@ with 'Reflex::Role::Timeout' => {
method_stop => "stop",
};
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/UdpPeer.pm
@@ -26,6 +26,8 @@ with 'Reflex::Role::Recving' => {
cb_error => make_terminal_emitter(on_error => "error"),
};
+__PACKAGE__->meta->make_immutable;
+
1;
__END__
View
2 lib/Reflex/Wakeup.pm
@@ -14,6 +14,8 @@ with 'Reflex::Role::Wakeup' => {
method_reset => "reset",
};
+__PACKAGE__->meta->make_immutable;
+
1;
__END__

0 comments on commit 5bc7069

Please sign in to comment.
Something went wrong with that request. Please try again.