Skip to content

Commit 93fbaf8

Browse files
committed
---
yaml --- r: 148891 b: refs/heads/try2 c: 6c41192 h: refs/heads/master i: 148889: 06ed495 148887: bbe48da v: v3
1 parent ae88d60 commit 93fbaf8

File tree

18 files changed

+69
-464
lines changed

18 files changed

+69
-464
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: cdc678945fec211b06b6ec4ba059b8259dfeb2c2
8+
refs/heads/try2: 6c41192c4188ee3155d44a05a5e41e61088f1938
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libextra/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ Rust extras are part of the standard Rust distribution.
3434
#[deny(non_camel_case_types)];
3535
#[deny(missing_doc)];
3636

37-
#[cfg(stage0)]
38-
macro_rules! if_ok (
39-
($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
40-
)
41-
4237
// Utility modules
4338

4439
pub mod c_vec;

branches/try2/src/libextra/priority_queue.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,10 @@ impl<T:Ord> PriorityQueue<T> {
5151
/// Returns the number of elements the queue can hold without reallocating
5252
pub fn capacity(&self) -> uint { self.data.capacity() }
5353

54-
/// Reserve capacity for exactly n elements in the PriorityQueue.
55-
/// Do nothing if the capacity is already sufficient.
56-
pub fn reserve_exact(&mut self, n: uint) { self.data.reserve_exact(n) }
57-
58-
/// Reserve capacity for at least n elements in the PriorityQueue.
59-
/// Do nothing if the capacity is already sufficient.
60-
pub fn reserve(&mut self, n: uint) {
61-
self.data.reserve(n)
54+
pub fn reserve(&mut self, n: uint) { self.data.reserve(n) }
55+
56+
pub fn reserve_at_least(&mut self, n: uint) {
57+
self.data.reserve_at_least(n)
6258
}
6359

6460
/// Pop the greatest item from the queue - fails if empty
@@ -207,7 +203,7 @@ impl<T: Ord> Extendable<T> for PriorityQueue<T> {
207203
let (lower, _) = iter.size_hint();
208204

209205
let len = self.capacity();
210-
self.reserve(len + lower);
206+
self.reserve_at_least(len + lower);
211207

212208
for elem in *iter {
213209
self.push(elem);

branches/try2/src/libextra/ringbuf.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ impl<T> RingBuf<T> {
168168
/// # Arguments
169169
///
170170
/// * n - The number of elements to reserve space for
171-
pub fn reserve_exact(&mut self, n: uint) {
172-
self.elts.reserve_exact(n);
171+
pub fn reserve(&mut self, n: uint) {
172+
self.elts.reserve(n);
173173
}
174174

175175
/// Reserve capacity for at least `n` elements in the given RingBuf,
@@ -182,8 +182,8 @@ impl<T> RingBuf<T> {
182182
/// # Arguments
183183
///
184184
/// * n - The number of elements to reserve space for
185-
pub fn reserve(&mut self, n: uint) {
186-
self.elts.reserve(n);
185+
pub fn reserve_at_least(&mut self, n: uint) {
186+
self.elts.reserve_at_least(n);
187187
}
188188

189189
/// Front-to-back iterator.
@@ -641,26 +641,26 @@ mod tests {
641641
}
642642

643643
#[test]
644-
fn test_reserve_exact() {
644+
fn test_reserve() {
645645
let mut d = RingBuf::new();
646646
d.push_back(0u64);
647-
d.reserve_exact(50);
647+
d.reserve(50);
648648
assert_eq!(d.elts.capacity(), 50);
649649
let mut d = RingBuf::new();
650650
d.push_back(0u32);
651-
d.reserve_exact(50);
651+
d.reserve(50);
652652
assert_eq!(d.elts.capacity(), 50);
653653
}
654654

655655
#[test]
656-
fn test_reserve() {
656+
fn test_reserve_at_least() {
657657
let mut d = RingBuf::new();
658658
d.push_back(0u64);
659-
d.reserve(50);
659+
d.reserve_at_least(50);
660660
assert_eq!(d.elts.capacity(), 64);
661661
let mut d = RingBuf::new();
662662
d.push_back(0u32);
663-
d.reserve(50);
663+
d.reserve_at_least(50);
664664
assert_eq!(d.elts.capacity(), 64);
665665
}
666666

branches/try2/src/librustc/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ use syntax::diagnostic::Emitter;
5454
use syntax::diagnostic;
5555
use syntax::parse;
5656

57-
#[cfg(stage0)]
58-
macro_rules! if_ok (
59-
($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
60-
)
61-
6257
pub mod middle {
6358
pub mod trans;
6459
pub mod ty;

branches/try2/src/librustc/middle/trans/adt.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
use std::container::Map;
4747
use std::libc::c_ulonglong;
4848
use std::option::{Option, Some, None};
49-
use std::num::{Bitwise};
5049

5150
use lib::llvm::{ValueRef, True, IntEQ, IntNE};
5251
use middle::trans::_match;
@@ -425,22 +424,19 @@ fn generic_type_of(cx: &CrateContext, r: &Repr, name: Option<&str>, sizing: bool
425424
let align = most_aligned.align;
426425
let discr_ty = ll_inttype(cx, ity);
427426
let discr_size = machine::llsize_of_alloc(cx, discr_ty) as u64;
428-
let align_units = (size + align - 1) / align - 1;
429427
let pad_ty = match align {
430-
1 => Type::array(&Type::i8(), align_units),
431-
2 => Type::array(&Type::i16(), align_units),
432-
4 => Type::array(&Type::i32(), align_units),
433-
8 if machine::llalign_of_min(cx, Type::i64()) == 8 =>
434-
Type::array(&Type::i64(), align_units),
435-
a if a.population_count() == 1 => Type::array(&Type::vector(&Type::i32(), a / 4),
436-
align_units),
428+
1 => Type::i8(),
429+
2 => Type::i16(),
430+
4 => Type::i32(),
431+
8 if machine::llalign_of_min(cx, Type::i64()) == 8 => Type::i64(),
437432
_ => fail!("Unsupported enum alignment: {:?}", align)
438433
};
439434
assert_eq!(machine::llalign_of_min(cx, pad_ty) as u64, align);
435+
let align_units = (size + align - 1) / align;
440436
assert_eq!(align % discr_size, 0);
441437
let fields = ~[discr_ty,
442-
Type::array(&discr_ty, align / discr_size - 1),
443-
pad_ty];
438+
Type::array(&discr_ty, align / discr_size - 1),
439+
Type::array(&pad_ty, align_units - 1)];
444440
match name {
445441
None => Type::struct_(fields, false),
446442
Some(name) => {

branches/try2/src/libstd/fmt/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,11 +493,6 @@ use util;
493493
use vec::ImmutableVector;
494494
use vec;
495495

496-
// NOTE this is just because the `prelude::*` import above includes
497-
// default::Default, so the reexport doesn't work.
498-
#[cfg(stage0)]
499-
pub use Default = fmt::Show; // export required for `format!()` etc.
500-
501496
pub mod parse;
502497
pub mod rt;
503498

branches/try2/src/libstd/hashmap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ impl<K: Hash + Eq, V> HashMap<K, V> {
384384
}
385385

386386
/// Reserve space for at least `n` elements in the hash table.
387-
pub fn reserve(&mut self, n: uint) {
387+
pub fn reserve_at_least(&mut self, n: uint) {
388388
if n > self.buckets.len() {
389389
let buckets = n * 4 / 3 + 1;
390390
self.resize(num::next_power_of_two(buckets));
@@ -793,8 +793,8 @@ impl<T:Hash + Eq> HashSet<T> {
793793
}
794794

795795
/// Reserve space for at least `n` elements in the hash table.
796-
pub fn reserve(&mut self, n: uint) {
797-
self.map.reserve(n)
796+
pub fn reserve_at_least(&mut self, n: uint) {
797+
self.map.reserve_at_least(n)
798798
}
799799

800800
/// Returns true if the hash set contains a value equivalent to the

branches/try2/src/libstd/reflect.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -446,15 +446,4 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
446446
if ! self.inner.visit_type() { return false; }
447447
true
448448
}
449-
450-
// NOTE remove after next snapshot
451-
#[cfg(stage0)]
452-
fn visit_closure_ptr(&mut self, ck: uint) -> bool {
453-
self.align_to::<proc()>();
454-
if ! self.inner.visit_closure_ptr(ck) {
455-
return false
456-
}
457-
self.bump_past::<proc()>();
458-
true
459-
}
460449
}

branches/try2/src/libstd/repr.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,10 +602,6 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
602602
fn visit_param(&mut self, _i: uint) -> bool { true }
603603
fn visit_self(&mut self) -> bool { true }
604604
fn visit_type(&mut self) -> bool { true }
605-
606-
// NOTE remove after next snapshot
607-
#[cfg(stage0)]
608-
fn visit_closure_ptr(&mut self, _ck: uint) -> bool { true }
609605
}
610606

611607
pub fn write_repr<T>(writer: &mut io::Writer, object: &T) -> io::IoResult<()> {

branches/try2/src/libstd/str.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ use iter::{Iterator, FromIterator, Extendable, range};
9191
use iter::{Filter, AdditiveIterator, Map};
9292
use iter::{Rev, DoubleEndedIterator, ExactSize};
9393
use libc;
94-
use num::Saturating;
94+
use num::{Saturating, checked_next_power_of_two};
9595
use option::{None, Option, Some};
9696
use ptr;
9797
use ptr::RawPtr;
@@ -163,7 +163,12 @@ pub fn from_char(ch: char) -> ~str {
163163

164164
/// Convert a vector of chars to a string
165165
pub fn from_chars(chs: &[char]) -> ~str {
166-
chs.iter().map(|c| *c).collect()
166+
let mut buf = ~"";
167+
buf.reserve(chs.len());
168+
for ch in chs.iter() {
169+
buf.push_char(*ch)
170+
}
171+
buf
167172
}
168173

169174
#[doc(hidden)]
@@ -847,7 +852,8 @@ pub fn utf16_chars(v: &[u16], f: |char|) {
847852

848853
/// Allocates a new string from the utf-16 slice provided
849854
pub fn from_utf16(v: &[u16]) -> ~str {
850-
let mut buf = with_capacity(v.len());
855+
let mut buf = ~"";
856+
buf.reserve(v.len());
851857
utf16_chars(v, |ch| buf.push_char(ch));
852858
buf
853859
}
@@ -2090,15 +2096,17 @@ impl<'a> StrSlice<'a> for &'a str {
20902096
}
20912097

20922098
fn escape_default(&self) -> ~str {
2093-
let mut out = with_capacity(self.len());
2099+
let mut out: ~str = ~"";
2100+
out.reserve_at_least(self.len());
20942101
for c in self.chars() {
20952102
c.escape_default(|c| out.push_char(c));
20962103
}
20972104
out
20982105
}
20992106

21002107
fn escape_unicode(&self) -> ~str {
2101-
let mut out = with_capacity(self.len());
2108+
let mut out: ~str = ~"";
2109+
out.reserve_at_least(self.len());
21022110
for c in self.chars() {
21032111
c.escape_unicode(|c| out.push_char(c));
21042112
}
@@ -2422,7 +2430,7 @@ pub trait OwnedStr {
24222430
///
24232431
/// * s - A string
24242432
/// * n - The number of bytes to reserve space for
2425-
fn reserve_exact(&mut self, n: uint);
2433+
fn reserve(&mut self, n: uint);
24262434

24272435
/// Reserves capacity for at least `n` bytes in the given string.
24282436
///
@@ -2440,7 +2448,7 @@ pub trait OwnedStr {
24402448
///
24412449
/// * s - A string
24422450
/// * n - The number of bytes to reserve space for
2443-
fn reserve(&mut self, n: uint);
2451+
fn reserve_at_least(&mut self, n: uint);
24442452

24452453
/// Returns the number of single-byte characters the string can hold without
24462454
/// reallocating
@@ -2466,7 +2474,7 @@ impl OwnedStr for ~str {
24662474
#[inline]
24672475
fn push_str_no_overallocate(&mut self, rhs: &str) {
24682476
let new_cap = self.len() + rhs.len();
2469-
self.reserve_exact(new_cap);
2477+
self.reserve(new_cap);
24702478
self.push_str(rhs);
24712479
}
24722480

@@ -2545,17 +2553,15 @@ impl OwnedStr for ~str {
25452553
}
25462554

25472555
#[inline]
2548-
fn reserve_exact(&mut self, n: uint) {
2556+
fn reserve(&mut self, n: uint) {
25492557
unsafe {
2550-
raw::as_owned_vec(self).reserve_exact(n)
2558+
raw::as_owned_vec(self).reserve(n)
25512559
}
25522560
}
25532561

25542562
#[inline]
2555-
fn reserve(&mut self, n: uint) {
2556-
unsafe {
2557-
raw::as_owned_vec(self).reserve(n)
2558-
}
2563+
fn reserve_at_least(&mut self, n: uint) {
2564+
self.reserve(checked_next_power_of_two(n).unwrap_or(n))
25592565
}
25602566

25612567
#[inline]
@@ -2613,7 +2619,7 @@ impl Extendable<char> for ~str {
26132619
fn extend<T: Iterator<char>>(&mut self, iterator: &mut T) {
26142620
let (lower, _) = iterator.size_hint();
26152621
let reserve = lower + self.len();
2616-
self.reserve(reserve);
2622+
self.reserve_at_least(reserve);
26172623
for ch in *iterator {
26182624
self.push_char(ch)
26192625
}

0 commit comments

Comments
 (0)