Mercurial > projects > ldc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1632:8c37dcd7cfde | 1633:5c0cebff9be8 |
---|---|
1 Index: tango/core/rt/compiler/ldc/rt/lifetime.d | |
2 =================================================================== | |
3 --- tango/core/rt/compiler/ldc/rt/lifetime.d (revision 5368) | |
4 +++ tango/core/rt/compiler/ldc/rt/lifetime.d (working copy) | |
5 @@ -786,6 +786,7 @@ | |
6 return *cast(long*)px; | |
7 } | |
8 | |
9 ++/ | |
10 | |
11 /** | |
12 * | |
13 @@ -849,10 +850,11 @@ | |
14 | |
15 | |
16 /** | |
17 - * | |
18 + * Appends a single element to an array. | |
19 */ | |
20 -extern (C) byte[] _d_arrayappendcT(TypeInfo ti, ref byte[] x, ...) | |
21 +extern (C) byte[] _d_arrayappendcT(TypeInfo ti, void* array, void* element) | |
22 { | |
23 + auto x = cast(byte[]*)array; | |
24 auto sizeelem = ti.next.tsize(); // array element size | |
25 auto info = gc_query(x.ptr); | |
26 auto length = x.length; | |
27 @@ -879,16 +881,16 @@ | |
28 assert(newcap >= newlength * sizeelem); | |
29 newdata = cast(byte *)gc_malloc(newcap + 1, info.attr); | |
30 memcpy(newdata, x.ptr, length * sizeelem); | |
31 - (cast(void**)(&x))[1] = newdata; | |
32 + (cast(void**)x)[1] = newdata; | |
33 } | |
34 L1: | |
35 - byte *argp = cast(byte *)(&ti + 2); | |
36 + byte *argp = cast(byte *)element; | |
37 | |
38 - *cast(size_t *)&x = newlength; | |
39 + *cast(size_t *)x = newlength; | |
40 x.ptr[length * sizeelem .. newsize] = argp[0 .. sizeelem]; | |
41 assert((cast(size_t)x.ptr & 15) == 0); | |
42 assert(gc_sizeOf(x.ptr) > x.length * sizeelem); | |
43 - return x; | |
44 + return *x; | |
45 } | |
46 | |
47 | |
48 @@ -1128,6 +1130,7 @@ | |
49 return result; | |
50 } | |
51 | |
52 +/+ | |
53 | |
54 /** | |
55 * |