Skip to content
This repository
Browse code

Use a shared preallocated null capture

  • Loading branch information...
commit 7aef58292b603fc1e5f509e315b01e5cc3435448 1 parent 680f033
sorear authored October 03, 2010
4  lib/Kernel.cs
@@ -95,6 +95,8 @@ public abstract class Variable : IP6 {
95 95
 
96 96
         public abstract IP6  GetVar();
97 97
 
  98
+        public static readonly Variable[] None = new Variable[0];
  99
+
98 100
         public override DynMetaObject GetMO() { return null; }
99 101
     }
100 102
 
@@ -939,7 +941,7 @@ public class Kernel {
939 941
             th.MarkSharedChain();
940 942
             Thread thr = new Thread(delegate () {
941 943
                     Frame mark = new Frame(th, null, ExitRunloopSI);
942  
-                    Frame cur = sub.Invoke(mark, new Variable[0], null);
  944
+                    Frame cur = sub.Invoke(mark, Variable.None, null);
943 945
                     RunCore(cur);
944 946
                 });
945 947
             thr.Start();
2  perf/callmark.pl
@@ -29,4 +29,4 @@
29 29
 sub x29 () { x28; x28 } # 536870911
30 30
 sub x30 () { x29; x29 } # 1073741823
31 31
 
32  
-x27;
  32
+x30;
1  src/CLRTypes.pm
@@ -105,6 +105,7 @@ my %typedata = (
105 105
 
106 106
     'Lexer.RunProtoregex'  => [m => 'IP6[]'],
107 107
     'Lexer.GetLexer'       => [m => 'Lexer'],
  108
+    'Variable.None'        => [f => 'Variable[]'],
108 109
     'Kernel.SearchForHandler' => [c => 'Variable'],
109 110
     'Kernel.Die'           => [c => 'Variable'],
110 111
     'Kernel.BindFail'      => [c => 'Variable'],
10  src/CodeGen.pm
@@ -242,7 +242,9 @@ use CLRTypes;
242 242
         my $quick = 1;
243 243
         for (@$sig) { $quick &&= ($_ eq '') }
244 244
         my ($inv, @vals) = _odds(@args);
245  
-        if ($quick) {
  245
+        if (!@vals) {
  246
+            return $inv, "Variable.None", "null";
  247
+        } elsif ($quick) {
246 248
             return $inv, "new Variable[] { " . join(", ", @vals) . "}", "null";
247 249
         } else {
248 250
             # TODO: optimize harder
@@ -299,11 +301,17 @@ use CLRTypes;
299 301
 
300 302
     sub clr_new_arr {
301 303
         my ($self, $class, @args) = @_;
  304
+        if ($class eq 'Variable' && !@args) {
  305
+            return "Variable[]", "Variable.None";
  306
+        }
302 307
         $class . "[]", "new $class []{" .  join(", ", _odds @args) . "}";
303 308
     }
304 309
 
305 310
     sub clr_new_zarr {
306 311
         my ($self, $class, $nity, $nitems) = @_;
  312
+        if ($class eq 'Variable' && $nitems eq "0") {
  313
+            return "Variable[]", "Variable.None";
  314
+        }
307 315
         $class . "[]", "(new $class [$nitems])";
308 316
     }
309 317
 

0 notes on commit 7aef582

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