Skip to content

Commit 9c9376f

Browse files
committed
---
yaml --- r: 51134 b: refs/heads/try c: 3564389 h: refs/heads/master v: v3
1 parent ff3677e commit 9c9376f

File tree

14 files changed

+424
-654
lines changed

14 files changed

+424
-654
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 5f13e9ccc2e3328d4cd8ca49f84e6840dd998346
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: f7a2371c176663d59062ec5158f39faecba45768
5-
refs/heads/try: 706ed6dd532eaf8848e60f4368ad519647a41107
5+
refs/heads/try: 356438989830d8b9e597096a9d1ea2c7b6aa9af9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/hashmap.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,16 @@ pub mod linear {
393393
}
394394
}
395395
396-
pub impl<K:Hash + IterBytes + Eq,V> LinearMap<K, V> {
396+
pub impl<K: Hash + IterBytes + Eq, V> LinearMap<K, V> {
397397
/// Create an empty LinearMap
398398
fn new() -> LinearMap<K, V> {
399-
linear_map_with_capacity(INITIAL_CAPACITY)
399+
LinearMap::with_capacity(INITIAL_CAPACITY)
400+
}
401+
402+
/// Create an empty LinearMap with space for at least `n` elements in
403+
/// the hash table.
404+
fn with_capacity(capacity: uint) -> LinearMap<K, V> {
405+
linear_map_with_capacity(capacity)
400406
}
401407
402408
/// Reserve space for at least `n` elements in the hash table.
@@ -652,7 +658,15 @@ pub mod linear {
652658

653659
pub impl <T:Hash + IterBytes + Eq> LinearSet<T> {
654660
/// Create an empty LinearSet
655-
fn new() -> LinearSet<T> { LinearSet{map: LinearMap::new()} }
661+
fn new() -> LinearSet<T> {
662+
LinearSet::with_capacity(INITIAL_CAPACITY)
663+
}
664+
665+
/// Create an empty LinearSet with space for at least `n` elements in
666+
/// the hash table.
667+
fn with_capacity(capacity: uint) -> LinearSet<T> {
668+
LinearSet { map: LinearMap::with_capacity(capacity) }
669+
}
656670

657671
/// Reserve space for at least `n` elements in the hash table.
658672
fn reserve_at_least(&mut self, n: uint) {

branches/try/src/libcore/vec.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,28 @@ pub fn consume<T>(mut v: ~[T], f: &fn(uint, v: T)) {
560560
}
561561
}
562562
563+
pub fn consume_reverse<T>(mut v: ~[T], f: &fn(uint, v: T)) {
564+
unsafe {
565+
do as_mut_buf(v) |p, ln| {
566+
let mut i = ln;
567+
while i > 0 {
568+
i -= 1;
569+
570+
// NB: This unsafe operation counts on init writing 0s to the
571+
// holes we create in the vector. That ensures that, if the
572+
// iterator fails then we won't try to clean up the consumed
573+
// elements during unwinding
574+
let mut x = intrinsics::init();
575+
let p = ptr::mut_offset(p, i);
576+
x <-> *p;
577+
f(i, x);
578+
}
579+
}
580+
581+
raw::set_len(&mut v, 0);
582+
}
583+
}
584+
563585
/// Remove the last element from a vector and return it
564586
pub fn pop<T>(v: &mut ~[T]) -> T {
565587
let ln = v.len();
@@ -1985,6 +2007,7 @@ pub trait OwnedVector<T> {
19852007
fn truncate(&mut self, newlen: uint);
19862008
fn retain(&mut self, f: &fn(t: &T) -> bool);
19872009
fn consume(self, f: &fn(uint, v: T));
2010+
fn consume_reverse(self, f: &fn(uint, v: T));
19882011
fn filter(self, f: &fn(t: &T) -> bool) -> ~[T];
19892012
fn partition(self, f: &fn(&T) -> bool) -> (~[T], ~[T]);
19902013
fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>);
@@ -2046,6 +2069,11 @@ impl<T> OwnedVector<T> for ~[T] {
20462069
consume(self, f)
20472070
}
20482071

2072+
#[inline]
2073+
fn consume_reverse(self, f: &fn(uint, v: T)) {
2074+
consume_reverse(self, f)
2075+
}
2076+
20492077
#[inline]
20502078
fn filter(self, f: &fn(&T) -> bool) -> ~[T] {
20512079
filter(self, f)

branches/try/src/librustc/middle/astencode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ trait read_method_map_entry_helper {
558558
fn encode_method_map_entry(ecx: @e::EncodeContext,
559559
ebml_w: writer::Encoder,
560560
mme: method_map_entry) {
561-
do ebml_w.emit_rec {
561+
do ebml_w.emit_struct("method_map_entry", 3) {
562562
do ebml_w.emit_field(~"self_arg", 0u) {
563563
ebml_w.emit_arg(ecx, mme.self_arg);
564564
}
@@ -574,7 +574,7 @@ fn encode_method_map_entry(ecx: @e::EncodeContext,
574574
impl read_method_map_entry_helper for reader::Decoder {
575575
fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext)
576576
-> method_map_entry {
577-
do self.read_rec {
577+
do self.read_struct("method_map_entry", 3) {
578578
method_map_entry {
579579
self_arg: self.read_field(~"self_arg", 0u, || {
580580
self.read_arg(xcx)
@@ -817,7 +817,7 @@ impl ebml_writer_helpers for writer::Encoder {
817817
818818
fn emit_tpbt(&self, ecx: @e::EncodeContext,
819819
tpbt: ty::ty_param_bounds_and_ty) {
820-
do self.emit_rec {
820+
do self.emit_struct("ty_param_bounds_and_ty", 3) {
821821
do self.emit_field(~"bounds", 0) {
822822
do self.emit_from_vec(*tpbt.bounds) |bs| {
823823
self.emit_bounds(ecx, *bs);
@@ -1084,7 +1084,7 @@ impl ebml_decoder_decoder_helpers for reader::Decoder {
10841084
fn read_ty_param_bounds_and_ty(&self, xcx: @ExtendedDecodeContext)
10851085
-> ty::ty_param_bounds_and_ty
10861086
{
1087-
do self.read_rec {
1087+
do self.read_struct("ty_param_bounds_and_ty", 3) {
10881088
ty::ty_param_bounds_and_ty {
10891089
bounds: self.read_field(~"bounds", 0u, || {
10901090
@self.read_to_vec(|| self.read_bounds(xcx) )

branches/try/src/libstd/ebml.rs

Lines changed: 35 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -311,23 +311,10 @@ pub mod reader {
311311
fn read_f64(&self) -> f64 { fail!(~"read_f64()"); }
312312
fn read_f32(&self) -> f32 { fail!(~"read_f32()"); }
313313
fn read_float(&self) -> float { fail!(~"read_float()"); }
314-
315314
fn read_char(&self) -> char { fail!(~"read_char()"); }
316-
317-
fn read_owned_str(&self) -> ~str { doc_as_str(self.next_doc(EsStr)) }
318-
fn read_managed_str(&self) -> @str { fail!(~"read_managed_str()"); }
315+
fn read_str(&self) -> ~str { doc_as_str(self.next_doc(EsStr)) }
319316
320317
// Compound types:
321-
fn read_owned<T>(&self, f: &fn() -> T) -> T {
322-
debug!("read_owned()");
323-
f()
324-
}
325-
326-
fn read_managed<T>(&self, f: &fn() -> T) -> T {
327-
debug!("read_managed()");
328-
f()
329-
}
330-
331318
fn read_enum<T>(&self, name: &str, f: &fn() -> T) -> T {
332319
debug!("read_enum(%s)", name);
333320
self._check_label(name);
@@ -361,34 +348,20 @@ pub mod reader {
361348
f()
362349
}
363350
364-
fn read_owned_vec<T>(&self, f: &fn(uint) -> T) -> T {
365-
debug!("read_owned_vec()");
351+
fn read_seq<T>(&self, f: &fn(uint) -> T) -> T {
352+
debug!("read_seq()");
366353
do self.push_doc(self.next_doc(EsVec)) {
367354
let len = self._next_uint(EsVecLen);
368355
debug!(" len=%u", len);
369356
f(len)
370357
}
371358
}
372359
373-
fn read_managed_vec<T>(&self, f: &fn(uint) -> T) -> T {
374-
debug!("read_managed_vec()");
375-
do self.push_doc(self.next_doc(EsVec)) {
376-
let len = self._next_uint(EsVecLen);
377-
debug!(" len=%u", len);
378-
f(len)
379-
}
380-
}
381-
382-
fn read_vec_elt<T>(&self, idx: uint, f: &fn() -> T) -> T {
383-
debug!("read_vec_elt(idx=%u)", idx);
360+
fn read_seq_elt<T>(&self, idx: uint, f: &fn() -> T) -> T {
361+
debug!("read_seq_elt(idx=%u)", idx);
384362
self.push_doc(self.next_doc(EsVecElt), f)
385363
}
386364
387-
fn read_rec<T>(&self, f: &fn() -> T) -> T {
388-
debug!("read_rec()");
389-
f()
390-
}
391-
392365
fn read_struct<T>(&self, name: &str, _len: uint, f: &fn() -> T) -> T {
393366
debug!("read_struct(name=%s)", name);
394367
f()
@@ -400,16 +373,6 @@ pub mod reader {
400373
f()
401374
}
402375
403-
fn read_tup<T>(&self, len: uint, f: &fn() -> T) -> T {
404-
debug!("read_tup(len=%u)", len);
405-
f()
406-
}
407-
408-
fn read_tup_elt<T>(&self, idx: uint, f: &fn() -> T) -> T {
409-
debug!("read_tup_elt(idx=%u)", idx);
410-
f()
411-
}
412-
413376
#[cfg(stage0)]
414377
fn read_option<T>(&self, f: &fn(bool) -> T) -> T {
415378
debug!("read_option()");
@@ -439,6 +402,21 @@ pub mod reader {
439402
}
440403
}
441404
}
405+
406+
fn read_map<T>(&self, _f: &fn(uint) -> T) -> T {
407+
debug!("read_map()");
408+
fail!(~"read_map is unimplemented");
409+
}
410+
411+
fn read_map_elt_key<T>(&self, idx: uint, _f: &fn() -> T) -> T {
412+
debug!("read_map_elt_key(idx=%u)", idx);
413+
fail!(~"read_map_elt_val is unimplemented");
414+
}
415+
416+
fn read_map_elt_val<T>(&self, idx: uint, _f: &fn() -> T) -> T {
417+
debug!("read_map_elt_val(idx=%u)", idx);
418+
fail!(~"read_map_elt_val is unimplemented");
419+
}
442420
}
443421
}
444422
@@ -650,22 +628,10 @@ pub mod writer {
650628
fail!(~"Unimplemented: serializing a char");
651629
}
652630
653-
fn emit_borrowed_str(&self, v: &str) {
631+
fn emit_str(&self, v: &str) {
654632
self.wr_tagged_str(EsStr as uint, v)
655633
}
656634
657-
fn emit_owned_str(&self, v: &str) {
658-
self.emit_borrowed_str(v)
659-
}
660-
661-
fn emit_managed_str(&self, v: &str) {
662-
self.emit_borrowed_str(v)
663-
}
664-
665-
fn emit_borrowed(&self, f: &fn()) { f() }
666-
fn emit_owned(&self, f: &fn()) { f() }
667-
fn emit_managed(&self, f: &fn()) { f() }
668-
669635
fn emit_enum(&self, name: &str, f: &fn()) {
670636
self._emit_label(name);
671637
self.wr_tag(EsEnum as uint, f)
@@ -677,35 +643,23 @@ pub mod writer {
677643
}
678644
fn emit_enum_variant_arg(&self, _idx: uint, f: &fn()) { f() }
679645
680-
fn emit_borrowed_vec(&self, len: uint, f: &fn()) {
646+
fn emit_seq(&self, len: uint, f: &fn()) {
681647
do self.wr_tag(EsVec as uint) {
682648
self._emit_tagged_uint(EsVecLen, len);
683649
f()
684650
}
685651
}
686652
687-
fn emit_owned_vec(&self, len: uint, f: &fn()) {
688-
self.emit_borrowed_vec(len, f)
689-
}
690-
691-
fn emit_managed_vec(&self, len: uint, f: &fn()) {
692-
self.emit_borrowed_vec(len, f)
693-
}
694-
695-
fn emit_vec_elt(&self, _idx: uint, f: &fn()) {
653+
fn emit_seq_elt(&self, _idx: uint, f: &fn()) {
696654
self.wr_tag(EsVecElt as uint, f)
697655
}
698656
699-
fn emit_rec(&self, f: &fn()) { f() }
700657
fn emit_struct(&self, _name: &str, _len: uint, f: &fn()) { f() }
701658
fn emit_field(&self, name: &str, _idx: uint, f: &fn()) {
702659
self._emit_label(name);
703660
f()
704661
}
705662
706-
fn emit_tup(&self, _len: uint, f: &fn()) { f() }
707-
fn emit_tup_elt(&self, _idx: uint, f: &fn()) { f() }
708-
709663
fn emit_option(&self, f: &fn()) {
710664
self.emit_enum("Option", f);
711665
}
@@ -715,6 +669,18 @@ pub mod writer {
715669
fn emit_option_some(&self, f: &fn()) {
716670
self.emit_enum_variant("Some", 1, 1, f)
717671
}
672+
673+
fn emit_map(&self, _len: uint, _f: &fn()) {
674+
fail!(~"emit_map is unimplemented");
675+
}
676+
677+
fn emit_map_elt_key(&self, _idx: uint, _f: &fn()) {
678+
fail!(~"emit_map_elt_key is unimplemented");
679+
}
680+
681+
fn emit_map_elt_val(&self, _idx: uint, _f: &fn()) {
682+
fail!(~"emit_map_elt_val is unimplemented");
683+
}
718684
}
719685
}
720686

branches/try/src/libstd/flatpipes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@ pub mod flatteners {
466466
fn from_writer(w: @Writer) -> Self;
467467
}
468468
469-
impl<'self> FromReader for json::Decoder<'self> {
470-
fn from_reader(r: @Reader) -> json::Decoder<'self> {
469+
impl FromReader for json::Decoder {
470+
fn from_reader(r: @Reader) -> json::Decoder {
471471
match json::from_reader(r) {
472472
Ok(json) => {
473473
json::Decoder(json)

0 commit comments

Comments
 (0)