I've been spending the past couple days working on moving the current vector +
operator into libcore, instead of being generated by trans. It's looking like
our inlining code is smart enough to make vec::push perform as well as the old
+= operator did. Of course, now the += operator as implemented in libcore must
always do a copy on the left hand side, which means its performance is so bad
as to be basically unusable.
On Jun 13, 2012, at 4:31 PM, Brian Anderson wrote:
> On 06/13/2012 04:15 PM, Niko Matsakis wrote:
>> Hello,
>>
>> I wanted to check something. We are working on the Great Change to a
>> more flexible vector system and I want to outline the design that's in
>> my head. This has some implications for How Efficient Rust Code Is
>> Written, so I wanted to make sure we were all on the same page.
>>
>> *Implications for writing efficient Rust*
>>
>> I figured I'd just start with the implications for writing Rust.
>> Currently, to build up a vector, we rely upon an idiom like:
>>
>> let mut v = [];
>> for some loop { v += [elt]; }
>>
>> Now, often, such loops can (and should) be written using a higher-order
>> function (e.g., map, filter). But sometimes not. In such cases, under
>> the new regime, the recommended idiom would be:
>>
>> let dv = dvec();
>> for some loop { v.push(elt); }
>> let v = dvec::unwrap(dv); // if necessary, convert to a vector
>
> This method of creating vectors originally had worse performance than the
> other. Is the performance problem resolved or resolvable or is vector
> creation just going to be expensive?
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev