LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "runtime.h" | 5 #include "runtime.h" |
6 #include "arch_GOARCH.h" | 6 #include "arch_GOARCH.h" |
7 #include "type.h" | 7 #include "type.h" |
8 #include "typekind.h" | 8 #include "typekind.h" |
9 #include "malloc.h" | 9 #include "malloc.h" |
10 #include "race.h" | 10 #include "race.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // write x[len(x):len(x)+len(y)] | 88 // write x[len(x):len(x)+len(y)] |
89 if(m <= x.cap) | 89 if(m <= x.cap) |
90 runtime·racewriterangepc(ret.array+ret.len*w, y.len*w, p
c, runtime·appendslice); | 90 runtime·racewriterangepc(ret.array+ret.len*w, y.len*w, p
c, runtime·appendslice); |
91 } | 91 } |
92 | 92 |
93 // A very common case is appending bytes. Small appends can avoid the ov
erhead of memmove. | 93 // A very common case is appending bytes. Small appends can avoid the ov
erhead of memmove. |
94 // We can generalize a bit here, and just pick small-sized appends. | 94 // We can generalize a bit here, and just pick small-sized appends. |
95 p = ret.array+ret.len*w; | 95 p = ret.array+ret.len*w; |
96 q = y.array; | 96 q = y.array; |
97 w *= y.len; | 97 w *= y.len; |
98 » if(appendCrossover && w <= appendCrossover) { | 98 » if(appendCrossover > 0 && w <= appendCrossover) { |
99 if(p <= q || w <= p-q) // No overlap. | 99 if(p <= q || w <= p-q) // No overlap. |
100 while(w-- > 0) | 100 while(w-- > 0) |
101 *p++ = *q++; | 101 *p++ = *q++; |
102 else { | 102 else { |
103 p += w; | 103 p += w; |
104 q += w; | 104 q += w; |
105 while(w-- > 0) | 105 while(w-- > 0) |
106 *--p = *--q; | 106 *--p = *--q; |
107 } | 107 } |
108 } else { | 108 } else { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 runtime·racereadrangepc(x.array, x.len, pc, runtime·appe
ndstr); | 141 runtime·racereadrangepc(x.array, x.len, pc, runtime·appe
ndstr); |
142 // write x[len(x):len(x)+len(y)] | 142 // write x[len(x):len(x)+len(y)] |
143 if(m <= x.cap) | 143 if(m <= x.cap) |
144 runtime·racewriterangepc(ret.array+ret.len, y.len, pc, r
untime·appendstr); | 144 runtime·racewriterangepc(ret.array+ret.len, y.len, pc, r
untime·appendstr); |
145 } | 145 } |
146 | 146 |
147 // Small appends can avoid the overhead of memmove. | 147 // Small appends can avoid the overhead of memmove. |
148 w = y.len; | 148 w = y.len; |
149 p = ret.array+ret.len; | 149 p = ret.array+ret.len; |
150 q = y.str; | 150 q = y.str; |
151 » if(appendCrossover && w <= appendCrossover) { | 151 » if(appendCrossover > 0 && w <= appendCrossover) { |
152 while(w-- > 0) | 152 while(w-- > 0) |
153 *p++ = *q++; | 153 *p++ = *q++; |
154 } else { | 154 } else { |
155 runtime·memmove(p, q, w); | 155 runtime·memmove(p, q, w); |
156 } | 156 } |
157 ret.len += y.len; | 157 ret.len += y.len; |
158 FLUSH(&ret); | 158 FLUSH(&ret); |
159 } | 159 } |
160 | 160 |
161 | 161 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 void | 289 void |
290 runtime·printslice(Slice a) | 290 runtime·printslice(Slice a) |
291 { | 291 { |
292 runtime·prints("["); | 292 runtime·prints("["); |
293 runtime·printint(a.len); | 293 runtime·printint(a.len); |
294 runtime·prints("/"); | 294 runtime·prints("/"); |
295 runtime·printint(a.cap); | 295 runtime·printint(a.cap); |
296 runtime·prints("]"); | 296 runtime·prints("]"); |
297 runtime·printpointer(a.array); | 297 runtime·printpointer(a.array); |
298 } | 298 } |
LEFT | RIGHT |