DEV Community

Discussion on: Optimizing Immutable Strings in Rust

Collapse
 
somedood profile image
Basti Ortiz

How did you get to the conclusion that there are only as many bytes allocated by Arc as T takes?

Ah, that is my mistake. I have totally missed that! My original conception of the article came from one of my projects when I realized that I could use a Box<str> over a String. Then, as I wrote this article, I wanted to apply the same optimization over multi-threaded contexts via Arc. It had not occurred to me (until you mentioned it) that Arc actually has some overhead due to atomics, which Box does not have. I had falsely assumed otherwise.

This led to my incorrect conclusion that Arc allocates as Box would. So to make a long story short, I had unintentionally disregarded the Arc overhead, thinking that it was a Box.

Thanks for pointing this out! I shall edit the article accordingly.