Commit Graph

20852 Commits

Author SHA1 Message Date
Young-il Choi
b32617666a std: run test fix for ARM android 2013-08-07 19:01:43 +09:00
bors
4da1cfe923 auto merge of #8285 : huonw/rust/deriving+++, r=alexcrichton
Some general clean-up relating to deriving:
- `TotalOrd` was too eager, and evaluated the `.cmp` call for every field, even if it could short-circuit earlier.
- the pointer types didn't have impls for `TotalOrd` or `TotalEq`.
- the Makefiles didn't reach deep enough into libsyntax for dependencies.

(Split out from https://github.com/mozilla/rust/pull/8258.)
2013-08-07 00:56:18 -07:00
Huon Wilson
4f3944a34f Add test for short-circuiting #[deriving(Eq,Ord,TotalEq,TotalOrd)]. 2013-08-07 16:56:50 +10:00
bors
62dbdc4ea2 auto merge of #8287 : sfackler/rust/hex, r=alexcrichton
FromHex ignores whitespace and parses either upper or lower case hex
digits. ToHex outputs lower case hex digits with no whitespace. Unlike
ToBase64, ToHex doesn't allow you to configure the output format. I
don't feel that it's super useful in this case.
2013-08-06 21:05:11 -07:00
bors
5b4244d917 auto merge of #8231 : SimonSapin/rust/ascii-upper-lower-case, r=cmr
Original pull request: Add str.to_ascii_lower() and str.to_ascii_upper() methods in std::str.
2013-08-06 15:32:05 -07:00
Simon Sapin
88b21f592c Add to_ascii_upper, to_ascii_lower and eq_ignore_ascii_case in std::ascii 2013-08-06 20:22:11 +01:00
bors
6972eb4cd7 auto merge of #8321 : alexcrichton/rust/enable-rusti, r=cmr
Now that LLVM has been upgraded, I think that we can try again to re-enable the rusti tests.
2013-08-06 12:14:07 -07:00
Steven Fackler
3b441c485f Result::get -> Result::unwrap 2013-08-06 10:42:06 -07:00
bors
72080954b9 auto merge of #8317 : bblum/rust/fast-spawn-unlinked, r=brson
This lazily initializes the taskgroup structs for ```spawn_unlinked``` tasks. If such a task never spawns another task linked to it (or a descendant of it), its taskgroup is simply never initialized at all. Also if an unlinked task spawns another unlinked task, neither of them will need to initialize their taskgroups. This works for the main task too.

I benchmarked this with the following test case and observed a ~~21% speedup (average over 4 runs: 7.85 sec -> 6.20 sec, 2.5 GHz)~~ 11% speedup, see comment below.
```
use std::task;
use std::cell::Cell;
use std::rt::comm;

static NUM: uint = 1024*256;

fn run(f: ~fn()) {
    let mut t = task::task();
    t.unlinked();
    t.spawn(f);
}

fn main() {
    do NUM.times {
        let (p,c) = comm::oneshot();
        let c = Cell::new(c);
        do run { c.take().send(()); }
        p.recv();
    }
}
```
2013-08-06 10:32:00 -07:00
Steven Fackler
e617651384 Removed convenience encoding trait impls
Encoding should really only be done from [u8]<->str. The extra
convenience implementations don't really have a place, especially since
they're so trivial.

Also improved error messages in FromBase64.
2013-08-06 09:58:36 -07:00
Steven Fackler
858e166119 Removing space for NULL terminator
String NULL terminators are going away soon, so we may as well get rid
of this now so it doesn't rot.
2013-08-06 09:58:36 -07:00
Steven Fackler
ff5fdffc13 ToBase64 and ToHex perf improvements
The overhead of str::push_char is high enough to cripple the performance
of these two functions. I've switched them to build the output in a
~[u8] and then convert to a string later. Since we know exactly the
bytes going into the vector, we can use the unsafe version to avoid the
is_utf8 check.

I could have riced it further with vec::raw::get, but it only added
~10MB/s so I didn't think it was worth it. ToHex is still ~30% slower
than FromHex, which is puzzling.

Before:

```
test base64::test::from_base64 ... bench: 1000 ns/iter (+/- 349) = 204 MB/s
test base64::test::to_base64 ... bench: 2390 ns/iter (+/- 1130) = 63 MB/s
...
test hex::tests::bench_from_hex ... bench: 884 ns/iter (+/- 220) = 341 MB/s
test hex::tests::bench_to_hex ... bench: 2453 ns/iter (+/- 919) = 61 MB/s
```

After:

```
test base64::test::from_base64 ... bench: 1271 ns/iter (+/- 600) = 160 MB/s
test base64::test::to_base64 ... bench: 759 ns/iter (+/- 286) = 198 MB/s
...
test hex::tests::bench_from_hex ... bench: 875 ns/iter (+/- 377) = 345 MB/s
test hex::tests::bench_to_hex ... bench: 593 ns/iter (+/- 240) = 254 MB/s
```
2013-08-06 09:58:36 -07:00
Steven Fackler
463e2416e9 Some minor hex changes 2013-08-06 09:58:36 -07:00
Steven Fackler
2266df51aa Added hexadecimal encoding module
FromHex ignores whitespace and parses either upper or lower case hex
digits. ToHex outputs lower case hex digits with no whitespace. Unlike
ToBase64, ToHex doesn't allow you to configure the output format. I
don't feel that it's super useful in this case.
2013-08-06 09:58:35 -07:00
bors
3dfb55ab09 auto merge of #8313 : msullivan/rust/cleanup, r=catamorphism 2013-08-06 08:44:05 -07:00
bors
ba3d03d3a4 auto merge of #8312 : alexcrichton/rust/use-treemap, r=erickt
Closes #4430
2013-08-06 07:05:05 -07:00
bors
ca6385034c auto merge of #8308 : blake2-ppc/rust/str-slice-bytes, r=alexcrichton
`fn slice_bytes` is marked unsafe since it allows violating the valid
string encoding property; but the function did also allow extending the
lifetime of the slice by mistake, since it's returning `&str`.

Use the annotation `slice_bytes<'a>(&'a str, ...) -> &'a str` so
that all uses of `slice_bytes` are region checked correctly.
2013-08-06 05:26:01 -07:00
bors
8adcba4300 auto merge of #8054 : sammykim/rust/move-EnumSet, r=alexcrichton
Fix #8004
2013-08-06 02:26:06 -07:00
Sangeun Kim
a76943be47 Move EnumSet into libextra 2013-08-06 14:45:02 +09:00
bors
f8cf234b34 auto merge of #8265 : blake2-ppc/rust/std-iter, r=thestinger
Fix #8228 by replacing .iter() and .iter_err() in Result by external iterators.

Implement random access for `iterator::Invert` and `vec::ChunkIter` (and bidirectionality).

Implement Repeat iterator.
2013-08-05 22:38:15 -07:00
bors
6f88f4dea5 auto merge of #8278 : cmr/rust/workaround, r=brson 2013-08-05 20:07:59 -07:00
blake2-ppc
45085b9f8d std: Fix bug in ChunkIter::idx
ChunkIter .idx() didn't handle overflow correctly, even though it tried.
2013-08-06 04:05:08 +02:00
blake2-ppc
ea9c5c405e std: Remove uint::iterate, replaced by range 2013-08-06 04:05:08 +02:00
blake2-ppc
08d0b70213 extra: Simplify the bitv iterators using Repeat 2013-08-06 04:05:08 +02:00
blake2-ppc
b5cd81d0e5 std: Improve the documentation for iterator::Invert 2013-08-06 04:05:08 +02:00
blake2-ppc
520f292e48 std: Use method name Option::consume
With Option as the simplest container, `consume` is the way to turn it
into a by-value iterator.
2013-08-06 04:05:07 +02:00
blake2-ppc
78effe7626 std: Rewrite the HashSet set operation iterators
Use the Repeat iterator to carry the "explicit closure capture" that was
previously done with the custom EnvFilterIterator.
2013-08-06 04:05:07 +02:00
blake2-ppc
8046218f0f std: Add iterator::Repeat to repeat an element endlessly 2013-08-06 04:05:07 +02:00
blake2-ppc
a05a9a1c02 std: Improve vec::ChunkIter
Implement clone, bidirectionality and random access for this iterator
2013-08-06 04:05:07 +02:00
blake2-ppc
872d15d464 std: Implement RandomAccessIterator for Invert 2013-08-06 04:05:07 +02:00
blake2-ppc
c5e4c55989 std: Remove unused trait bound in Result::map 2013-08-06 04:05:07 +02:00
blake2-ppc
109e0d85a1 std: Convert Result to use external iterators
convert iter() and iter_err() for Result. Use OptionIterator.
2013-08-06 04:02:21 +02:00
blake2-ppc
ce682cb45f std: Add .consume_iter() for Option, to make it reusable
Let Option be a base for a widely useful one- or zero- item iterator.
Refactor OptionIterator to support any generic element type, so the same
iterator impl can be used for both &T, &mut T and T iterators.
2013-08-06 03:59:56 +02:00
Alex Crichton
d5de801cc1 Re-enable rusti tests 2013-08-05 18:55:53 -07:00
bors
bbda3fa938 auto merge of #8288 : Kimundi/rust/opteitres4, r=brson
This is an alternative version to https://github.com/mozilla/rust/pull/8268, where instead of transitioning to `get()` completely, I transitioned to `unwrap()` completely.

My reasoning for also opening this PR is that having two different functions with identical behavior on a common datatype is bad for consistency and confusing for users, and should be solved as soon as possible. The fact that apparently half the code uses `get()`, and the other half `unwrap()` only makes it worse.

If the final naming decision ends up different, there needs to be a big renaming anyway, but until then it should at least be consistent.

---

- Made naming schemes consistent between Option, Result and Either
- Lifted the quality of the either and result module to that of option
- Changed Options Add implementation to work like the maybe Monad (return None if any of the inputs is None)  
  See https://github.com/mozilla/rust/issues/6002, especially my last comment.
- Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead  
  See also https://github.com/mozilla/rust/issues/7887.

Todo: 

Adding testcases for all function in the three modules. Even without the few functions I added, the coverage wasn't complete to begin with. But I'd rather do that as a follow up PR, I've touched to much code here already, need to go through them again later.
2013-08-05 16:47:01 -07:00
Ben Blum
1f95bd7684 Lazily initialize 'leaf node' taskgroups for unlinked spawns, for an apparent 11% speedup. 2013-08-05 19:30:25 -04:00
Ben Blum
47e82c8555 (cleanup) Uncomment an assertion that now holds. 2013-08-05 18:40:42 -04:00
bors
29099e450a auto merge of #8298 : darkf/rust/fix-3948, r=pcwalton 2013-08-05 13:49:55 -07:00
Marvin Löbel
0ac7a219f0 Updated std::Option, std::Either and std::Result
- Made naming schemes consistent between Option, Result and Either
- Changed Options Add implementation to work like the maybe monad (return None if any of the inputs is None)
- Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead
2013-08-05 22:42:21 +02:00
Alex Crichton
991648d099 Use TreeMap's ord implementation for Json
Closes #4430
2013-08-05 13:20:48 -07:00
Michael Sullivan
53c6de5684 Improve debug spew in _match. 2013-08-05 12:30:28 -07:00
Michael Sullivan
7dbc5ae79f Get rid of some NOTEs. 2013-08-05 12:30:28 -07:00
Michael Sullivan
fd01031f3a Warn when using -o option on libraries. Closes #6554. 2013-08-05 11:41:06 -07:00
Michael Sullivan
a20081666b Fix an unused variable warning and clean up some dead code/names. 2013-08-05 11:41:06 -07:00
bors
d8b299d179 auto merge of #8293 : dim-an/rust/trie-iterator, r=thestinger
Closes #5506.
2013-08-05 11:28:56 -07:00
Michael Sullivan
bcf62e7901 Make node_id_to_str print more useful info in some cases. Closes #2410. 2013-08-05 10:33:55 -07:00
bors
2d1eb1916e auto merge of #8292 : thestinger/rust/fix_loop_warning, r=brson 2013-08-05 09:49:56 -07:00
blake2-ppc
476dfc24b3 std: Use correct lifetime parameter on str::raw::slice_bytes
fn slice_bytes is marked unsafe since it allows violating the valid
string encoding property; but the function did also allow extending the
lifetime of the slice by mistake, since it's returning `&str`.

Use the annotation `slice_bytes<'a>(&'a str, ...) -> &'a str` so
that all uses of slice_bytes are region checked correctly.
2013-08-05 17:55:06 +02:00
bors
d89ff7eef9 auto merge of #8289 : sfackler/rust/push_byte, r=erickt
It was previously pushing the byte on top of the string's null
terminator. I added a test to make sure it doesn't break in the future.
2013-08-05 08:10:55 -07:00
bors
c2bacd2e80 auto merge of #8183 : omasanori/rust/migrate-new, r=sanxiyn
It seems that relatively new code uses `Foo::new()` instead of `Foo()` so I wrote a patch to migrate some structs to the former style.
Is it a right direction? If there are any guidelines not to use new()-style, could you add them to the [style guide](https://github.com/omasanori/rust/wiki/Note-style-guide)?
2013-08-05 06:22:57 -07:00