Skip to content

Commit 8b1f525

Browse files
author
Daniel Patterson
committed
---
yaml --- r: 29963 b: refs/heads/incoming c: 6083409 h: refs/heads/master i: 29961: 2d3f582 29959: 7c54d82 v: v3
1 parent 3918b74 commit 8b1f525

File tree

9 files changed

+26
-387
lines changed

9 files changed

+26
-387
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: 236f8330072aec35f875f029dc215769e5fc6b91
9+
refs/heads/incoming: 6083409f172c8bbea59cec4bac749c46057b4774
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/core.rc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ export hash;
5555
export cmp;
5656
export num;
5757
export path;
58-
export managed;
5958

6059
// NDM seems to be necessary for resolve to work
6160
export option_iter;
@@ -262,7 +261,6 @@ mod sys;
262261
#[warn(non_camel_case_types)]
263262
mod unsafe;
264263

265-
mod managed;
266264

267265
// Modules supporting compiler-generated code
268266
// Exported but not part of the public interface

branches/incoming/src/libcore/managed.rs

Lines changed: 0 additions & 62 deletions
This file was deleted.

branches/incoming/src/libcore/os.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ fn pipe() -> {in: c_int, out: c_int} {
358358
}
359359

360360
fn dup2(src: c_int, dst: c_int) -> c_int {
361-
libc::dup2(src, dst)
361+
libc::dup2(src, dst)
362362
}
363363

364364

@@ -963,9 +963,6 @@ mod tests {
963963
setenv(~"USERPROFILE", ~"/home/MountainView");
964964
assert os::homedir() == some(~"/home/MountainView");
965965

966-
setenv(~"USERPROFILE", ~"/home/MountainView");
967-
assert os::homedir() == some(~"/home/MountainView");
968-
969966
setenv(~"HOME", ~"/home/MountainView");
970967
setenv(~"USERPROFILE", ~"/home/PaloAlto");
971968
assert os::homedir() == some(~"/home/MountainView");

branches/incoming/src/libcore/send_map.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ mod linear {
5858
buckets: vec::from_fn(initial_capacity, |_i| none)})
5959
}
6060

61+
// FIXME(#2979) would allow us to use region type for k
62+
unsafe fn borrow<K>(&&k: K) -> &K {
63+
let p: *K = ptr::addr_of(k);
64+
unsafe::reinterpret_cast(p)
65+
}
66+
6167
priv impl<K, V> &const LinearMap<K,V> {
6268
#[inline(always)]
6369
pure fn to_bucket(h: uint) -> uint {
@@ -149,7 +155,8 @@ mod linear {
149155
/// Assumes that there will be a bucket.
150156
/// True if there was no previous entry with that key
151157
fn insert_internal(hash: uint, +k: K, +v: V) -> bool {
152-
match self.bucket_for_key_with_hash(self.buckets, hash, &k) {
158+
match self.bucket_for_key_with_hash(self.buckets, hash,
159+
unsafe{borrow(k)}) {
153160
TableFull => {fail ~"Internal logic error";}
154161
FoundHole(idx) => {
155162
debug!{"insert fresh (%?->%?) at idx %?, hash %?",
@@ -180,7 +187,7 @@ mod linear {
180187
self.expand();
181188
}
182189

183-
let hash = self.hashfn(&k);
190+
let hash = self.hashfn(unsafe{borrow(k)});
184191
self.insert_internal(hash, k, v)
185192
}
186193

@@ -221,13 +228,6 @@ mod linear {
221228
self.size -= 1;
222229
return true;
223230
}
224-
225-
fn clear() {
226-
for uint::range(0, self.buckets.len()) |idx| {
227-
self.buckets[idx] = none;
228-
}
229-
self.size = 0;
230-
}
231231
}
232232

233233
priv impl<K,V> &LinearMap<K,V> {
@@ -279,19 +279,11 @@ mod linear {
279279

280280
impl<K,V> &LinearMap<K,V> {
281281
/*
282-
FIXME(#3148)--region inference fails to capture needed deps
283-
284-
fn find_ref(k: &K) -> option<&self/V> {
285-
match self.bucket_for_key(self.buckets, k) {
286-
FoundEntry(idx) => {
287-
match check self.buckets[idx] {
288-
some(ref bkt) => some(&bkt.value)
289-
}
290-
}
291-
TableFull | FoundHole(_) => {
292-
none
293-
}
294-
}
282+
FIXME --- #2979 must be fixed to typecheck this
283+
fn find_ptr(k: K) -> option<&V> {
284+
//XXX this should not type check as written, but it should
285+
//be *possible* to typecheck it...
286+
self.with_ptr(k, |v| v)
295287
}
296288
*/
297289

branches/incoming/src/libcore/util.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,6 @@ pure fn id<T>(+x: T) -> T { x }
1212
/// Ignores a value.
1313
pure fn ignore<T>(+_x: T) { }
1414

15-
/// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the
16-
/// original value of `*ptr`.
17-
#[inline(always)]
18-
fn with<T: copy, R>(
19-
ptr: &mut T,
20-
+new_value: T,
21-
op: &fn() -> R) -> R
22-
{
23-
// NDM: if swap operator were defined somewhat differently,
24-
// we wouldn't need to copy...
25-
26-
let old_value = *ptr;
27-
*ptr = move new_value;
28-
let result = op();
29-
*ptr = move old_value;
30-
return move result;
31-
}
32-
3315
/**
3416
* Swap the values at two mutable locations of the same type, without
3517
* deinitialising or copying either one.

branches/incoming/src/libstd/map.rs

Lines changed: 7 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
import io::WriterUtil;
66
import to_str::ToStr;
7-
import managed::Managed;
8-
import send_map::linear::LinearMap;
9-
107
export hashmap, hashfn, eqfn, set, map, chained, hashmap, str_hash;
118
export box_str_hash;
129
export bytes_hash, int_hash, uint_hash, set_add;
@@ -62,10 +59,10 @@ trait map<K: copy, V: copy> {
6259
fn find(+key: K) -> option<V>;
6360

6461
/**
65-
* Remove and return a value from the map. Returns true if the
66-
* key was present in the map, otherwise false.
62+
* Remove and return a value from the map. If the key does not exist
63+
* in the map then returns none.
6764
*/
68-
fn remove(+key: K) -> bool;
65+
fn remove(+key: K) -> option<V>;
6966

7067
/// Clear the map, removing all key/value pairs.
7168
fn clear();
@@ -282,18 +279,18 @@ mod chained {
282279
option::unwrap(opt_v)
283280
}
284281

285-
fn remove(+k: K) -> bool {
282+
fn remove(+k: K) -> option<V> {
286283
match self.search_tbl(&k, self.hasher(&k)) {
287-
not_found => false,
284+
not_found => none,
288285
found_first(idx, entry) => {
289286
self.count -= 1u;
290287
self.chains[idx] = entry.next;
291-
true
288+
some(entry.value)
292289
}
293290
found_after(eprev, entry) => {
294291
self.count -= 1u;
295292
eprev.next = entry.next;
296-
true
293+
some(entry.value)
297294
}
298295
}
299296
}
@@ -471,93 +468,6 @@ fn hash_from_uints<V: copy>(items: &[(uint, V)]) -> hashmap<uint, V> {
471468
hash_from_vec(uint::hash, uint::eq, items)
472469
}
473470

474-
// XXX Transitionary
475-
impl<K: copy, V: copy> Managed<LinearMap<K, V>>: map<K, V> {
476-
fn size() -> uint {
477-
do self.borrow_const |p| {
478-
p.len()
479-
}
480-
}
481-
482-
fn insert(+key: K, +value: V) -> bool {
483-
do self.borrow_mut |p| {
484-
p.insert(key, value)
485-
}
486-
}
487-
488-
fn contains_key(+key: K) -> bool {
489-
do self.borrow_const |p| {
490-
p.contains_key(&key)
491-
}
492-
}
493-
494-
fn contains_key_ref(key: &K) -> bool {
495-
do self.borrow_const |p| {
496-
p.contains_key(key)
497-
}
498-
}
499-
500-
fn get(+key: K) -> V {
501-
do self.borrow_const |p| {
502-
p.get(&key)
503-
}
504-
}
505-
506-
fn find(+key: K) -> option<V> {
507-
do self.borrow_const |p| {
508-
p.find(&key)
509-
}
510-
}
511-
512-
fn remove(+key: K) -> bool {
513-
do self.borrow_mut |p| {
514-
p.remove(&key)
515-
}
516-
}
517-
518-
fn clear() {
519-
do self.borrow_mut |p| {
520-
p.clear()
521-
}
522-
}
523-
524-
fn each(op: fn(+key: K, +value: V) -> bool) {
525-
do self.borrow_imm |p| {
526-
p.each(op)
527-
}
528-
}
529-
530-
fn each_key(op: fn(+key: K) -> bool) {
531-
do self.borrow_imm |p| {
532-
p.each_key(op)
533-
}
534-
}
535-
536-
fn each_value(op: fn(+value: V) -> bool) {
537-
do self.borrow_imm |p| {
538-
p.each_value(op)
539-
}
540-
}
541-
542-
fn each_ref(op: fn(key: &K, value: &V) -> bool) {
543-
do self.borrow_imm |p| {
544-
p.each_ref(op)
545-
}
546-
}
547-
548-
fn each_key_ref(op: fn(key: &K) -> bool) {
549-
do self.borrow_imm |p| {
550-
p.each_key_ref(op)
551-
}
552-
}
553-
554-
fn each_value_ref(op: fn(value: &V) -> bool) {
555-
do self.borrow_imm |p| {
556-
p.each_value_ref(op)
557-
}
558-
}
559-
}
560-
561471
#[cfg(test)]
562472
mod tests {
563473

branches/incoming/src/libstd/smallintmap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ impl<V: copy> smallintmap<V>: map::map<uint, V> {
8080
insert(self, key, value);
8181
return !exists;
8282
}
83-
fn remove(+key: uint) -> bool {
83+
fn remove(+key: uint) -> option<V> {
8484
if key >= self.v.len() {
85-
return false;
85+
return none;
8686
}
8787
let old = self.v.get_elt(key);
8888
self.v.set_elt(key, none);
89-
old.is_some()
89+
old
9090
}
9191
fn clear() {
9292
self.v.set(~[mut]);

0 commit comments

Comments
 (0)