about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-09-26 23:51:13 -0700
committerbors <bors@rust-lang.org>2013-09-26 23:51:13 -0700
commitd6774f8c3992332c8958b10582083d3cff1bd5e1 (patch)
tree3108abb230cd72722e8f9cd1cfdb14db9aa067b0 /src/rustllvm/RustWrapper.cpp
parenteb3ebb7ebddcf3ee84e57af19dd863e27d747416 (diff)
parentb1ee87f402f929689fc028010c450184f661db3b (diff)
downloadrust-d6774f8c3992332c8958b10582083d3cff1bd5e1.tar.gz
rust-d6774f8c3992332c8958b10582083d3cff1bd5e1.zip
auto merge of #9352 : erickt/rust/master, r=huonw
One of the downsides with `c_str` is that it always forces an allocation, and so this could add unnecessary overhead to various calls. This PR implements one of the suggestions @graydon made in #8296 for `vec.with_c_str` in that for a short string can use a small stack array instead of a malloced array for our temporary c string. This ends up being twice as fast for small strings.

There are two things to consider before landing this commit though. First off, I arbitrarily picked the stack array as 32 bytes, and I'm not sure if this a reasonable amount or not. Second, there is a risk that someone can keep a reference to the interior stack pointer, which could cause mayhem if someone were to dereference the pointer. Since we also can easily grab and return interior pointers to vecs though, I don't think this is that much of an issue.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions