diff tango-0.99.9.patch @ 1633:5c0cebff9be8

Improve array append performance. Actually use the appropriate runtime function, instead of just growing the array by one!
author Christian Kamm <kamm incasoftware de>
date Sun, 14 Feb 2010 10:11:05 +0100
parents
children 40bd4a0d4870
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tango-0.99.9.patch	Sun Feb 14 10:11:05 2010 +0100
@@ -0,0 +1,55 @@
+Index: tango/core/rt/compiler/ldc/rt/lifetime.d
+===================================================================
+--- tango/core/rt/compiler/ldc/rt/lifetime.d	(revision 5368)
++++ tango/core/rt/compiler/ldc/rt/lifetime.d	(working copy)
+@@ -786,6 +786,7 @@
+     return *cast(long*)px;
+ }
+ 
+++/
+ 
+ /**
+  *
+@@ -849,10 +850,11 @@
+ 
+ 
+ /**
+- *
++ * Appends a single element to an array.
+  */
+-extern (C) byte[] _d_arrayappendcT(TypeInfo ti, ref byte[] x, ...)
++extern (C) byte[] _d_arrayappendcT(TypeInfo ti, void* array, void* element)
+ {
++    auto x = cast(byte[]*)array;
+     auto sizeelem = ti.next.tsize();            // array element size
+     auto info = gc_query(x.ptr);
+     auto length = x.length;
+@@ -879,16 +881,16 @@
+         assert(newcap >= newlength * sizeelem);
+         newdata = cast(byte *)gc_malloc(newcap + 1, info.attr);
+         memcpy(newdata, x.ptr, length * sizeelem);
+-        (cast(void**)(&x))[1] = newdata;
++        (cast(void**)x)[1] = newdata;
+     }
+   L1:
+-    byte *argp = cast(byte *)(&ti + 2);
++    byte *argp = cast(byte *)element;
+ 
+-    *cast(size_t *)&x = newlength;
++    *cast(size_t *)x = newlength;
+     x.ptr[length * sizeelem .. newsize] = argp[0 .. sizeelem];
+     assert((cast(size_t)x.ptr & 15) == 0);
+     assert(gc_sizeOf(x.ptr) > x.length * sizeelem);
+-    return x;
++    return *x;
+ }
+ 
+ 
+@@ -1128,6 +1130,7 @@
+     return result;
+ }
+ 
++/+
+ 
+ /**
+  *