From 61b5e488e960c8c90fa32cab97542e8d10cccd5b Mon Sep 17 00:00:00 2001 From: Ben Davies Date: Tue, 31 Mar 2020 19:27:43 -0300 Subject: [PATCH] Only bind to @!list in Capture.BUILD if the list given isn't empty This should save some memory. --- src/core.c/Capture.pm6 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core.c/Capture.pm6 b/src/core.c/Capture.pm6 index b13f7ca3ec1..58ed91c4ea1 100644 --- a/src/core.c/Capture.pm6 +++ b/src/core.c/Capture.pm6 @@ -6,10 +6,10 @@ my class Capture { # declared in BOOTSTRAP method from-args(|c) { c } submethod BUILD(:@list, :%hash --> Nil) { - @list.elems; # force reification of all + my Int:D $elems = @list.elems; # force reification of all nqp::bindattr(self, Capture, '@!list', - nqp::getattr(nqp::decont(@list.list), List, '$!reified') - ); + nqp::getattr(nqp::decont(@list.list), List, '$!reified')) + if $elems; nqp::bindattr(self,Capture,'%!hash', nqp::getattr(nqp::decont(%hash),Map,'$!storage')) if nqp::attrinited(nqp::decont(%hash),Map,'$!storage')