git » homepage.git » master » tree

[master] / archive / forums / hacker-news / raw / items / 9146272.json

{"by":"pcwalton","id":9146272,"kids":[9146506,9147155,9154007],"parent":9146206,"text":"Just one glance at the Rust version (e.g. [1]) shows a lot of needless allocation. For example:<p><pre><code>    if *strn == &quot;&amp;&quot;.to_string() { ... }\n</code></pre>\nis a very slow (and verbose) way to write<p><pre><code>    if &amp;strn[..] == &quot;&amp;&quot; { ... }\n</code></pre>\nand<p><pre><code>    rr_string(&quot;&#x27;&quot;.to_string() + k.to_string() + &quot;&#x27; not found&quot;.to_string())\n</code></pre>\nis a very slow (and verbose) way to write<p><pre><code>    rr_string(format!(&quot;&#x27;{}&#x27; not found&quot;, k))`\n</code></pre>\nEtc. etc.<p>[1]: <a href=\"https://github.com/kanaka/mal/blob/master/rust/src/env.rs\" rel=\"nofollow\">https:&#x2F;&#x2F;github.com&#x2F;kanaka&#x2F;mal&#x2F;blob&#x2F;master&#x2F;rust&#x2F;src&#x2F;env.rs</a>","time":1425493838,"type":"comment"}