Now I'm confused; doesn't this mean str is fixed size, so the proposal to
just use "str" for the 3-word struct and have ~str and &str just be the
normal thing makes sense after all?

On Fri, Nov 8, 2013 at 8:56 PM, Marvin Löbel <loebel.mar...@gmail.com>wrote:

> On 11/08/2013 07:50 PM, Igor Bukanov wrote:
>
>> On 8 November 2013 18:35, Patrick Walton <pcwal...@mozilla.com> wrote:
>>
>>> But Daniel did some performance measurements and found that this had
>>> suboptimal performance characteristics when compared to:
>>>
>>>      struct ~str {
>>>          char *ptr;
>>>          int size;
>>>          int cap;
>>>      }
>>>
>>> So we're changing to the latter.
>>>
>> Does this mean that when ~str is passed as a parameter the compiler
>> copies 3 words and that makes things faster?
>>
> According to https://github.com/mozilla/rust/issues/8981, yes and yes
> apparently. :)
>
> You rarely pass around a ~[T] directly anyway, usually you work with
> slices to them, which right now consist of exactly two words. (Though that
> might change to three words too for unrelated consistency reasons)
>
> Other speed improvements come from the fact that empty vectors no longer
> allocate, and that you no longer need to dereference a pointer into heap
> memory to get the size of an vector.
>
>
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to