bors
576f395ddf
auto merge of #8121 : thestinger/rust/offset, r=alexcrichton
...
Closes #8118 , #7136
~~~rust
extern mod extra;
use std::vec;
use std::ptr;
fn bench_from_elem(b: &mut extra::test::BenchHarness) {
do b.iter {
let v: ~[u8] = vec::from_elem(1024, 0u8);
}
}
fn bench_set_memory(b: &mut extra::test::BenchHarness) {
do b.iter {
let mut v: ~[u8] = vec::with_capacity(1024);
unsafe {
let vp = vec::raw::to_mut_ptr(v);
ptr::set_memory(vp, 0, 1024);
vec::raw::set_len(&mut v, 1024);
}
}
}
fn bench_vec_repeat(b: &mut extra::test::BenchHarness) {
do b.iter {
let v: ~[u8] = ~[0u8, ..1024];
}
}
~~~
Before:
test bench_from_elem ... bench: 415 ns/iter (+/- 17)
test bench_set_memory ... bench: 85 ns/iter (+/- 4)
test bench_vec_repeat ... bench: 83 ns/iter (+/- 3)
After:
test bench_from_elem ... bench: 84 ns/iter (+/- 2)
test bench_set_memory ... bench: 84 ns/iter (+/- 5)
test bench_vec_repeat ... bench: 84 ns/iter (+/- 3)
2013-07-30 07:01:19 -07:00
Marvin Löbel
e33fca9ffe
Added str::char_offset_iter() and str::rev_char_offset_iter()
...
Renamed bytes_iter to byte_iter to match other iterators
Refactored str Iterators to use DoubleEnded Iterators and typedefs instead of wrapper structs
Reordered the Iterator section
Whitespace fixup
Moved clunky `each_split_within` function to the one place in the tree where it's actually needed
Replaced all block doccomments in str with line doccomments
2013-07-30 12:55:48 +02:00
Daniel Micay
ef870d37a5
implement pointer arithmetic with GEP
...
Closes #8118 , #7136
~~~rust
extern mod extra;
use std::vec;
use std::ptr;
fn bench_from_elem(b: &mut extra::test::BenchHarness) {
do b.iter {
let v: ~[u8] = vec::from_elem(1024, 0u8);
}
}
fn bench_set_memory(b: &mut extra::test::BenchHarness) {
do b.iter {
let mut v: ~[u8] = vec::with_capacity(1024);
unsafe {
let vp = vec::raw::to_mut_ptr(v);
ptr::set_memory(vp, 0, 1024);
vec::raw::set_len(&mut v, 1024);
}
}
}
fn bench_vec_repeat(b: &mut extra::test::BenchHarness) {
do b.iter {
let v: ~[u8] = ~[0u8, ..1024];
}
}
~~~
Before:
test bench_from_elem ... bench: 415 ns/iter (+/- 17)
test bench_set_memory ... bench: 85 ns/iter (+/- 4)
test bench_vec_repeat ... bench: 83 ns/iter (+/- 3)
After:
test bench_from_elem ... bench: 84 ns/iter (+/- 2)
test bench_set_memory ... bench: 84 ns/iter (+/- 5)
test bench_vec_repeat ... bench: 84 ns/iter (+/- 3)
2013-07-30 02:50:31 -04:00
blake2-ppc
5307d3674e
std: Implement Extendable for hashmap, str and trie
2013-07-30 02:32:38 +02:00
blake2-ppc
4b45f47881
std: Rename Iterator adaptor types to drop the -Iterator suffix
...
Drop the "Iterator" suffix for the the structs in std::iterator.
Filter, Zip, Chain etc. are shorter type names for when iterator
pipelines need their types written out in full in return value types, so
it's easier to read and write. the iterator module already forms enough
namespace.
2013-07-29 04:20:56 +02:00
blake2-ppc
4849a42bf6
std: Implement FromIterator for ~str
...
FromIterator initially only implemented for Iterator<char>, which is the
type of the main iterator.
2013-07-29 02:40:28 +02:00
jmgrosen
a0f0f3012e
Refactored vec and str iterators to remove prefixes
2013-07-28 13:37:35 -07:00
bors
5157e05049
auto merge of #8036 : sfackler/rust/container-impls, r=msullivan
...
A couple of implementations of Container::is_empty weren't exactly
self.len() == 0 so I left them alone (e.g. Treemap).
2013-07-27 11:16:31 -07:00
Alex Crichton
5aaaca0c6a
Consolidate raw representations of rust values
...
This moves the raw struct layout of closures, vectors, boxes, and strings into a
new `unstable::raw` module. This is meant to be a centralized location to find
information for the layout of these values.
As safe method, `repr`, is provided to convert a rust value to its raw
representation. Unsafe methods to convert back are not provided because they are
rarely used and too numerous to write an implementation for each (not much of a
common pattern).
2013-07-26 09:53:03 -07:00
Steven Fackler
feb18fe8da
Added default impls for container methods
...
A couple of implementations of Container::is_empty weren't exactly
self.len() == 0 so I left them alone (e.g. Treemap).
2013-07-25 15:17:30 -07:00
bors
330378d1a1
auto merge of #7996 : erickt/rust/cleanup-strs, r=erickt
...
This is a cleanup pull request that does:
* removes `os::as_c_charp`
* moves `str::as_buf` and `str::as_c_str` into `StrSlice`
* converts some functions from `StrSlice::as_buf` to `StrSlice::as_c_str`
* renames `StrSlice::as_buf` to `StrSlice::as_imm_buf` (and adds `StrSlice::as_mut_buf` to match `vec.rs`.
* renames `UniqueStr::as_bytes_with_null_consume` to `UniqueStr::to_bytes`
* and other misc cleanups and minor optimizations
2013-07-24 13:25:36 -07:00
Birunthan Mohanathas
d047cf1ec6
Change 'print(fmt!(...))' to printf!/printfln! in src/lib*
2013-07-24 09:45:20 -04:00
Erick Tryzelaar
9c3679a9a2
std: make str::append move self
...
This eliminates a copy and fixes a FIXME.
2013-07-23 16:57:00 -07:00
Erick Tryzelaar
bbedbc0450
std: inline str::with_capacity and vec::with_capacity
2013-07-23 16:57:00 -07:00
Erick Tryzelaar
cced3c9013
std: simplify str::as_imm_buf and vec::as_{imm,mut}_buf
2013-07-23 16:57:00 -07:00
Erick Tryzelaar
037a5b1af4
str: move as_mut_buf into OwnedStr, and make it self
2013-07-23 16:56:58 -07:00
Erick Tryzelaar
31b77aecfc
std: remove str::to_owned and str::raw::slice_bytes_owned
2013-07-23 16:56:23 -07:00
Erick Tryzelaar
cc9666f68f
std: rename str.as_buf to as_imm_buf, add str.as_mut_buf
2013-07-23 16:56:22 -07:00
Erick Tryzelaar
cf75330807
std: add test for str::as_c_str
2013-07-23 16:56:22 -07:00
Erick Tryzelaar
7af56bb921
std: move StrUtil::as_c_str into StrSlice
2013-07-23 16:56:22 -07:00
Erick Tryzelaar
9fdec67a67
std: move str::as_buf into StrSlice
2013-07-23 16:56:22 -07:00
Erick Tryzelaar
9ad815e063
std: rename str.as_bytes_with_null_consume to str.to_bytes_with_null
2013-07-23 16:56:17 -07:00
Graydon Hoare
978e5d94bc
std: wrap "long" utf8 lines.
2013-07-23 16:02:14 -07:00
Graydon Hoare
e5cbede103
std: add preliminary str benchmark.
2013-07-22 16:56:10 -07:00
Daniel Micay
ed67cdb73c
new snapshot
2013-07-22 01:09:48 -04:00
bors
fe3f75ff8e
auto merge of #7932 : blake2-ppc/rust/str-clear, r=huonw
...
~str and @str need separate implementations for use in generic
functions, where it will not automatically use the impl on &str.
fixes issue #7900
2013-07-21 15:28:38 -07:00
blake2-ppc
24b6901b26
std: Implement Clone for VecIterator and iterators using it
...
The theory is simple, the immutable iterators simply hold state
variables (indicies or pointers) into frozen containers. We can freely
clone these iterators, just like we can clone borrowed pointers.
VecIterator needs a manual impl to handle the lifetime struct member.
2013-07-20 20:30:57 +02:00
blake2-ppc
3509f9d5ae
str: Implement Container for ~str, @str and Mutable for ~str
...
~str and @str need separate implementations for use in generic
functions, where it will not automatically use the impl on &str.
2013-07-20 19:28:38 +02:00
Patrick Walton
99b33f7219
librustc: Remove all uses of "copy".
2013-07-17 14:57:51 -07:00
Daniel Micay
e118555ce6
remove headers from unique vectors
2013-07-15 23:57:27 -04:00
Gary Linscott
5aee5a11e3
Optimize is_utf8
...
Manually unroll the multibyte loops, and optimize for the single
byte chars.
2013-07-11 14:23:15 -04:00
Gary Linscott
179637304a
char_range_at perf work
...
Moves multibyte code to it's own function to make char_range_at
easier to inline, and faster for single and multibyte chars.
Benchmarked reading example.json 100 times, 1.18s before, 1.08s
after.
2013-07-11 14:23:14 -04:00
bors
30c8aac677
auto merge of #7612 : thestinger/rust/utf8, r=huonw
2013-07-08 16:10:53 -07:00
Daniel Micay
44770ae3a8
Merge pull request #7595 from thestinger/iterator
...
remove some method resolve workarounds
2013-07-08 01:42:07 -07:00
Daniel Micay
641aec7407
remove some method resolve workarounds
2013-07-07 19:51:13 -04:00
Daniel Micay
01833de7ea
remove extra::rope
...
It's broken/unmaintained and needs to be rewritten to avoid managed
pointers and needless copies. A full rewrite is necessary and the API
will need to be redone so it's not worth keeping this around.
Closes #2236 , #2744
2013-07-06 17:06:30 -04:00
Daniel Micay
51eb1e14d4
str: stop encoding invalid out-of-range char
2013-07-05 21:07:37 -04:00
Huon Wilson
cdea73cf5b
Convert vec::{as_imm_buf, as_mut_buf} to methods.
2013-07-04 00:46:50 +10:00
Huon Wilson
c437a16c5d
rustc: add a lint to enforce uppercase statics.
2013-07-01 17:52:57 +10:00
Alex Crichton
d3155faede
Specialize to_str_common for floats/integers in strconv
...
This allows the integral paths to avoid allocations on the heap
Closes #4424 , #4423
2013-06-30 09:19:25 -07:00
bors
c6b0d4f516
auto merge of #7475 : Seldaek/rust/fixsplit, r=cmr
...
I almost got locked out of my machine because I misunderstood the purpose of the function and called it with a limit of uint::max_value, which turned this function into an almost endless loop.
2013-06-29 21:13:31 -07:00
Alex Crichton
b29c368674
Removing a lot of usage of '&const'
2013-06-29 08:35:48 -07:00
Ben Blum
ff4ab9e147
'Borrow' stack closures rather than copying them (e.g., "|x|f(x)"), in prep for making them noncopyable.
2013-06-29 04:39:34 -04:00
Jordi Boggiano
647b4a6bcd
Optimize str::each_split_within when it is called with large limits
2013-06-29 04:53:52 +02:00
Patrick Walton
e015bee286
Rewrite each_path to allow performance improvements in the future.
...
Instead of determining paths from the path tag, we iterate through
modules' children recursively in the metadata. This will allow for
lazy external module resolution.
2013-06-28 10:44:16 -04:00
Patrick Walton
89eb995195
librustc: Fix merge fallout.
2013-06-28 10:44:16 -04:00
Patrick Walton
03ab6351cc
librustc: Rewrite reachability and forbid duplicate methods in type implementations.
...
This should allow fewer symbols to be exported.
2013-06-28 10:44:16 -04:00
Patrick Walton
8cd40f9032
libstd: Fix merge fallout.
2013-06-28 10:44:15 -04:00
Patrick Walton
f9b54541ee
librustc: Disallow "mut" from distributing over bindings.
...
This is the backwards-incompatible part of per-binding-site "mut".
2013-06-28 10:44:15 -04:00
bors
63afb8ccc8
auto merge of #7430 : huonw/rust/vec-kill, r=thestinger
2013-06-27 15:01:58 -07:00