Commit Graph

1971 Commits

Author SHA1 Message Date
bors
40e733a150 auto merge of #5209 : luqmana/rust/reader, r=graydon 2013-03-04 11:42:39 -08:00
bors
c639a78dc4 auto merge of #5205 : thestinger/rust/radix, r=graydon
This is an implementation of a map and set for integer keys. It's an ordered container (by byte order, which is sorted order for integers and byte strings when done in the right direction) with O(1) worst-case lookup, removal and insertion. There's no rebalancing or rehashing so it's actually O(1) without amortizing any costs.

The fanout can be adjusted in multiples of 2 from 2-ary through 256-ary, but it's hardcoded at 16-ary because there isn't a way to expose that in the type system yet. To keep things simple, it also only allows `uint` keys, but later I'll expand it to all the built-in integer types and byte arrays.

There's quite a bit of room for performance improvement, along with the boost that will come with dropping the headers on `Owned` `~` and getting rid of the overhead from the stack switches to the allocator. It currently does suffix compression for a single node and then splits into two n-ary trie nodes, which could be replaced with an array for at least 4-8 suffixes before splitting it. There's also the option of doing path compression, which may be a good or a bad idea and depends a lot on the data stored.

I want to share the test suite with the other maps so that's why I haven't duplicated all of the existing integer key tests in this file. I'll send in another pull request to deal with that.

Current benchmark numbers against the other map types:

    TreeMap:
     Sequential integers:
      insert: 0.798295
      search: 0.188931
      remove: 0.435923
     Random integers:
      insert: 1.557661
      search: 0.758325
      remove: 1.720527

    LinearMap:
     Sequential integers:
      insert: 0.272338
      search: 0.141179
      remove: 0.190273
     Random integers:
      insert: 0.293588
      search: 0.162677
      remove: 0.206142

    TrieMap:
     Sequential integers:
      insert: 0.0901
      search: 0.012223
      remove: 0.084139
     Random integers:
      insert: 0.392719
      search: 0.261632
      remove: 0.470401

@graydon is using an earlier version of this for the garbage collection implementation, so that's why I added this to libcore. I left out the `next` and `prev` methods *for now* because I just wanted the essentials first.
2013-03-04 08:21:47 -08:00
Jyun-Yan You
5150b9811b rustc: MIPS32 support 2013-03-03 19:27:27 -08:00
Luqman Aden
162c816e34 libcore: Add read_until to ReaderUtil. 2013-03-03 02:03:30 -08:00
bors
5655ae46a7 auto merge of #5197 : pcwalton/rust/fn-types, r=pcwalton
r? @catamorphism
2013-03-02 19:18:37 -08:00
bors
826644e8cb auto merge of #5114 : osaut/rust/incoming, r=brson
Several typos corrected in the comments of  src/libcore/iter.rs and 2013 added to the copyright header (as requested on CONTRIBUTING.md)
2013-03-02 18:21:39 -08:00
Patrick Walton
542119f61f libcore: Remove fn@, fn~, and fn& from libcore. rs=defun 2013-03-02 16:49:32 -08:00
Patrick Walton
97fd421319 librustc: Remove fn@, fn~, and fn& from librustc. rs=defun 2013-03-02 16:49:31 -08:00
Patrick Walton
a3f728238b librustc: Forbid chained imports and fix the logic for one-level renaming imports 2013-03-02 16:49:30 -08:00
bors
a14b489925 auto merge of #5199 : thestinger/rust/hashmap, r=brson
Closes #4764
2013-03-02 16:30:39 -08:00
Daniel Micay
3550233d37 inline the implementation of TotalOrd for integers 2013-03-02 16:30:42 -05:00
Daniel Micay
a4d22635e1 add an initial radix trie implementation 2013-03-02 16:29:41 -05:00
bors
2304fe6208 auto merge of #5196 : thestinger/rust/ord, r=catamorphism
This allows `TreeMap`/`TreeSet` to fully express their requirements and reduces the comparisons from ~1.5 per level to 1 which really helps for string keys.

I also added `ReverseIter` to the prelude exports because I forgot when I originally added it.
2013-03-02 05:15:39 -08:00
Daniel Micay
035233a259 treemap: reimplement using TotalOrd 2013-03-02 14:10:19 -05:00
Daniel Micay
ca1ceb15b1 add a TotalOrd trait 2013-03-02 14:10:16 -05:00
bors
5aca7d6aef auto merge of #5137 : yjh0502/rust/empty_struct, r=nikomatsakis
The fix is straight-forward, but there are several changes
while fixing the issue.

1) disallow `mut` keyword when making a new struct

In code base, there are following code,

```rust
struct Foo { mut a: int };
let a = Foo { mut a: 1 };
```

This is because of structural record, which is
deprecated corrently (see issue #3089) In structural
record, `mut` keyword should be allowd to control
mutability. But without structural record, we don't
need to allow `mut` keyword while constructing struct.

2) disallow structural records in parser level
This is related to 1). With structural records, there
is an ambiguity between empty block and empty struct
To solve the problem, I change parser to stop parsing
structural records. I think this is not a problem,
because structural records are not compiled already.

Misc. issues

There is an ambiguity between empty struct vs. empty match stmt.
with following code,

```rust
match x{} {}
```

Two interpretation is possible, which is listed blow

```rust
match (x{}) {} //  matching with newly-constructed empty struct
(match x{}) {}  //  matching with empty enum(or struct) x
                //  and then empty block
```

It seems that there is no such code in rust code base, but
there is one test which uses empty match statement:
https://github.com/mozilla/rust/blob/incoming/src/test/run-pass/issue-3037.rs

All other cases could be distinguished with look-ahead,
but this can't be. One possible solution is wrapping with
parentheses when matching with an uninhabited type.

```rust
enum what { }
fn match_with_empty(x: what) -> ~str {
    match (x) { //use parentheses to remove the ambiguity
    }
}
```
2013-03-02 04:21:38 -08:00
Daniel Micay
a4175c34c3 make LinearMap fields private
Closes #4764
2013-03-02 05:09:36 -05:00
Jihyun Yu
95bc9ea26d Remove REC, change related tests/docs 2013-03-02 12:57:05 +09:00
Brian Anderson
9639ca5aa8 core: Move core::rt to core::unstable::lang 2013-03-01 17:27:14 -08:00
Brian Anderson
bcf626812b Rename core::private to core::unstable. #4743 2013-03-01 14:55:47 -08:00
Patrick Walton
50c08dbf0d Merge pull request #5178 from catamorphism/constant-buffers
core: Address XXX, make static constants for strings used when stringify...
2013-03-01 08:44:47 -08:00
Patrick Walton
9519ee5d80 librustc: "APL2" -> "ASL2". rs=license-fix 2013-03-01 08:41:31 -08:00
Patrick Walton
c355f17943 Merge remote branch 'sevrak/issue-5164' into incoming 2013-03-01 08:39:02 -08:00
bors
1d34a55d88 auto merge of #5162 : brson/rust/fixmes, r=brson 2013-03-01 01:54:38 -08:00
bors
a660bb362c auto merge of #5180 : catamorphism/rust/post-snapshot, r=catamorphism
* Disallow structural records everywhere
* Remove all #[cfg(stage0)] stuff
* Remove the last deprecated modes in libcore
* Un-xfail a test
2013-02-28 22:45:37 -08:00
bors
b7e72974dc auto merge of #5147 : nikomatsakis/rust/remove-legacy-trait-table, r=nikomatsakis
r? @pcwalton
2013-02-28 21:39:39 -08:00
Tim Chevalier
6b6d15ac20 Remove code that was awaiting a snapshot
* Disallow structural records everywhere
* Remove all #[cfg(stage0)] stuff
* Remove the last deprecated modes in libcore
* Un-xfail a test
2013-02-28 20:30:50 -08:00
Niko Matsakis
4ecb672d7f Remove legacy object creation mode, and convert remaining uses of it 2013-02-28 20:28:04 -05:00
bors
916d1a9165 auto merge of #5176 : brson/rust/unwrap_shared_mutable_state, r=nikomatsakis
r?

This fixes the current [random failures](http://buildbot.rust-lang.org/builders/auto-linux/builds/291/steps/test/logs/stdio) on the bots and closes #4436 by removing `unwrap_shared_mutable_state` and the code that depends on it. The result is that ARC-like things will not be unwrappable. This feature is complex and is not used outside of test cases.

Note that there is not consensus to remove it.

(second commit)
2013-02-28 17:21:40 -08:00
Tim Chevalier
405a35c7f8 core: Address XXX, make static constants for strings used when stringifying floats 2013-02-28 16:49:02 -08:00
Brian Anderson
78d5091a4f core: Remove unwrap_shared_mutable_state. #4436 2013-02-28 15:20:40 -08:00
Alex Crichton
2df07ddc25 Fix implicit leaks of imports throughout libraries
Also touch up use of 'pub' and move some tests around so the tested functions
don't have to be 'pub'
2013-02-28 18:00:34 -05:00
Patrick Walton
09a2b4e599 librustc: Make methods private if the impl is private 2013-02-28 11:32:26 -08:00
Patrick Walton
107bf96ff0 librustc: Mark all type implementations public. rs=impl-publicity 2013-02-28 11:32:24 -08:00
sevrak
833ad6018e Fix license attribute on crates 2013-02-28 13:34:01 +00:00
bors
b171d0ef7b auto merge of #5159 : brson/rust/rtcall, r=brson 2013-02-28 01:12:38 -08:00
bors
c705440ee3 auto merge of #5155 : bstrie/rust/dedrop, r=pcwalton
This removes all but 6 uses of `drop {}` from the entire codebase. Removing any of the remaining uses causes various non-trivial bugs; I'll start reporting them once this gets merged.
2013-02-27 23:30:40 -08:00
bors
6bff18ea0d auto merge of #5098 : pkgw/rust/pr/issue4869, r=brson
See issue #4869. I'm not quite sure what constitutes "consensus from the core team" (cf. discussion in the issue), but this at least demonstrates that the proposed change is pretty straightforward.

After this change, there are no new test failures. I've un-ignored the `to_str` vectors test; it's not at all obvious to me why it'd be problematic, and it passes on my Linux machine.
2013-02-27 20:39:39 -08:00
Brian Anderson
4a04a188e3 Convert NOTEs to FIXMEs 2013-02-27 18:44:35 -08:00
Brian Anderson
2f858de1c3 Remove the last remnants of rtcalls 2013-02-27 18:34:04 -08:00
Ben Striegel
43d43adf6b Turn old drop blocks into Drop traits 2013-02-27 19:14:19 -05:00
bors
33e7a1f087 auto merge of #5145 : Kimundi/rust/incoming, r=catamorphism 2013-02-27 13:27:48 -08:00
Patrick Walton
07c3f5c0de librustc: Forbid pub or priv before trait implementations 2013-02-27 09:40:16 -08:00
Patrick Walton
573a31dfa7 libsyntax: Forbid mutable vectors. rs=demuting 2013-02-27 09:40:16 -08:00
Patrick Walton
8d7e6ef772 libsyntax: Forbid ~mut and ~const. rs=demuting 2013-02-27 09:40:15 -08:00
Marvin Löbel
c2be2ec42d Added ToStr implementations for &[T] and @[T] 2013-02-27 16:02:53 +01:00
bors
f4e8ac21cd auto merge of #5135 : brson/rust/start, r=pcwalton
r?

#3406

Pretty straightforward. I'm using opaque pointers instead trying to get trans and core to agree on the types of the main function and crate map. One oddity is that this required changing the order of the `-lrustrt` argument to the linker in order to resolve `upcall_new_stack`. Linkers are mysterious.
2013-02-26 23:45:39 -08:00
bors
99a902c81d auto merge of #5120 : jbclements/rust/macros-have-scope, r=pcwalton
r?

After this patch, macros declared in a module, function, or block can only be used inside of that module, function or block, with the exception of modules declared with the #[macro_escape] attribute; these modules allow macros to escape, and can be used as a limited macro export mechanism.

This pull request also includes miscellaneous comments, lots of new test cases, a few renamings, and a few as-yet-unused data definitions for hygiene.
2013-02-26 20:00:38 -08:00
Brian Anderson
f4327230fa Add a 'start' lang item and use it instead of rust_start 2013-02-26 19:43:26 -08:00
Luqman Aden
f460c2adf8 Move levenshtein distance fn to core::str. 2013-02-26 17:23:30 -08:00