CC: | Nicolas Rochelemagne <nicolas.rochelemagne [...] cpanel.net> |
Subject: | [PATCH] simple optimization by caching pack |
Date: | Wed, 23 Nov 2011 12:38:50 -0600 |
To: | bug-Danga-Socket [...] rt.cpan.org |
From: | nicolas.rochelemagne [...] cpanel.net |
From: Nicolas Rochelemagne <nicolas.rochelemagne@cpanel.net>
---
lib/Danga/Socket.pm | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/lib/Danga/Socket.pm b/lib/Danga/Socket.pm
index 9bebf54..8deeafc 100644
--- a/lib/Danga/Socket.pm
+++ b/lib/Danga/Socket.pm
@@ -139,6 +139,10 @@ use constant POLLERR => 8;
use constant POLLHUP => 16;
use constant POLLNVAL => 32;
+# caching pack used by tcp_cork
+use constant PACK_0 => pack("l", 0);
+use constant PACK_1 => pack("l", 1);
+
our $HAVE_KQUEUE = eval { require IO::KQueue; 1 };
our (
@@ -813,7 +817,7 @@ sub tcp_cork {
my $rv;
if (TCP_CORK) {
$rv = setsockopt($self->{sock}, IPPROTO_TCP, TCP_CORK,
- pack("l", $val ? 1 : 0));
+ $val ? PACK_0 : PACK_1);
} else {
# FIXME: implement freebsd *PUSH sockopts
$rv = 1;
--
1.7.7.1