From: Elizabeth Mattijsen Date: Fri, 5 Sep 2003 14:46:00 +0000 (+0200) Subject: threads/shared.pm: saves 4K per thread X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=df5c998e3f9219a80f4bdf527ae29d22354dd219;p=p5sagit%2Fp5-mst-13.2.git threads/shared.pm: saves 4K per thread Message-Id: From: Elizabeth Mattijsen p4raw-id: //depot/perl@21047 --- diff --git a/ext/threads/shared/shared.pm b/ext/threads/shared/shared.pm index 632040a..abeb1ac 100644 --- a/ext/threads/shared/shared.pm +++ b/ext/threads/shared/shared.pm @@ -18,22 +18,22 @@ BEGIN { push @EXPORT,'bless'; } else { - *share = \&share_disabled; - *cond_wait = \&cond_wait_disabled; - *cond_signal = \&cond_signal_disabled; - *cond_broadcast = \&cond_broadcast_disabled; - } -} +# String eval is generally evil, but we don't want these subs to exist at all +# if threads are loaded successfully. Vivifying them conditionally this way +# saves on average about 4K of memory per thread. -sub cond_wait_disabled (\[$@%]) { undef } -sub cond_signal_disabled (\[$@%]) { undef } -sub cond_broadcast_disabled (\[$@%]) { undef } -sub share_disabled (\[$@%]) { return $_[0] } + eval <<'EOD'; +sub cond_wait (\[$@%]) { undef } +sub cond_signal (\[$@%]) { undef } +sub cond_broadcast (\[$@%]) { undef } +sub share (\[$@%]) { return $_[0] } +EOD + } +} $threads::shared::threads_shared = 1; - sub threads::shared::tie::SPLICE { die "Splice not implemented for shared arrays";