File tree Expand file tree Collapse file tree 12 files changed +39
-36
lines changed Expand file tree Collapse file tree 12 files changed +39
-36
lines changed Original file line number Diff line number Diff line change @@ -583,12 +583,12 @@ pub mod bytepipes {
583
583
584
584
impl BytePort for PipeBytePort {
585
585
fn try_recv ( & self , count : uint ) -> Option < ~[ u8 ] > {
586
- if vec :: uniq_len ( & const * self . buf ) >= count {
586
+ if self . buf . len ( ) >= count {
587
587
let mut bytes = :: core:: util:: replace ( & mut * self . buf , ~[ ] ) ;
588
588
* self . buf = bytes. slice ( count, bytes. len ( ) ) . to_owned ( ) ;
589
589
bytes. truncate ( count) ;
590
590
return Some ( bytes) ;
591
- } else if vec :: uniq_len ( & const * self . buf ) > 0 {
591
+ } else if ! self . buf . is_empty ( ) {
592
592
let mut bytes = :: core:: util:: replace ( & mut * self . buf , ~[ ] ) ;
593
593
assert ! ( count > bytes. len( ) ) ;
594
594
match self . try_recv ( count - bytes. len ( ) ) {
@@ -598,7 +598,7 @@ pub mod bytepipes {
598
598
}
599
599
None => return None
600
600
}
601
- } else if vec :: uniq_len ( & const * self . buf ) == 0 {
601
+ } else /* empty */ {
602
602
match self . port . try_recv ( ) {
603
603
Some ( buf) => {
604
604
assert ! ( !buf. is_empty( ) ) ;
@@ -607,8 +607,6 @@ pub mod bytepipes {
607
607
}
608
608
None => return None
609
609
}
610
- } else {
611
- :: core:: util:: unreachable ( )
612
610
}
613
611
}
614
612
}
Original file line number Diff line number Diff line change @@ -879,8 +879,7 @@ impl io::Reader for TcpSocketBuf {
879
879
880
880
// If possible, copy up to `len` bytes from the internal
881
881
// `data.buf` into `buf`
882
- let nbuffered = vec:: uniq_len ( & const self . data . buf ) -
883
- self . data . buf_off ;
882
+ let nbuffered = self . data . buf . len ( ) - self . data . buf_off ;
884
883
let needed = len - count;
885
884
if nbuffered > 0 {
886
885
unsafe {
@@ -934,7 +933,7 @@ impl io::Reader for TcpSocketBuf {
934
933
}
935
934
fn read_byte ( & self ) -> int {
936
935
loop {
937
- if vec :: uniq_len ( & const self . data . buf ) > self . data . buf_off {
936
+ if self . data . buf . len ( ) > self . data . buf_off {
938
937
let c = self . data . buf [ self . data . buf_off ] ;
939
938
self . data . buf_off += 1 ;
940
939
return c as int
Original file line number Diff line number Diff line change @@ -35,10 +35,10 @@ impl<T:Ord> BaseIter<T> for PriorityQueue<T> {
35
35
36
36
impl < T : Ord > Container for PriorityQueue < T > {
37
37
/// Returns the length of the queue
38
- fn len ( & const self ) -> uint { vec :: uniq_len ( & const self . data ) }
38
+ fn len ( & self ) -> uint { self . data . len ( ) }
39
39
40
40
/// Returns true if a queue contains no elements
41
- fn is_empty ( & const self ) -> bool { self . len ( ) == 0 }
41
+ fn is_empty ( & self ) -> bool { self . len ( ) == 0 }
42
42
}
43
43
44
44
impl < T : Ord > Mutable for PriorityQueue < T > {
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ pub fn sha1() -> @Sha1 {
93
93
}
94
94
fn process_msg_block ( st : & mut Sha1State ) {
95
95
assert_eq ! ( st. h. len( ) , digest_buf_len) ;
96
- assert_eq ! ( vec :: uniq_len ( st. work_buf) , work_buf_len) ;
96
+ assert_eq ! ( st. work_buf. len ( ) , work_buf_len) ;
97
97
let mut t: int ; // Loop counter
98
98
let w = st. work_buf ;
99
99
Original file line number Diff line number Diff line change @@ -32,9 +32,9 @@ pub struct SmallIntMap<T> {
32
32
33
33
impl < V > Container for SmallIntMap < V > {
34
34
/// Return the number of elements in the map
35
- fn len ( & const self ) -> uint {
35
+ fn len ( & self ) -> uint {
36
36
let mut sz = 0 ;
37
- for uint:: range( 0 , vec :: uniq_len ( & const self. v) ) |i| {
37
+ for uint:: range( 0 , self . v. len ( ) ) |i| {
38
38
match self . v [ i] {
39
39
Some ( _) => sz += 1 ,
40
40
None => { }
@@ -44,7 +44,7 @@ impl<V> Container for SmallIntMap<V> {
44
44
}
45
45
46
46
/// Return true if the map contains no elements
47
- fn is_empty ( & const self ) -> bool { self . len ( ) == 0 }
47
+ fn is_empty ( & self ) -> bool { self . len ( ) == 0 }
48
48
}
49
49
50
50
impl < V > Mutable for SmallIntMap < V > {
@@ -199,12 +199,12 @@ pub struct SmallIntSet {
199
199
200
200
impl Container for SmallIntSet {
201
201
/// Return the number of elements in the map
202
- fn len ( & const self ) -> uint {
202
+ fn len ( & self ) -> uint {
203
203
self . map . len ( )
204
204
}
205
205
206
206
/// Return true if the map contains no elements
207
- fn is_empty ( & const self ) -> bool { self . len ( ) == 0 }
207
+ fn is_empty ( & self ) -> bool { self . len ( ) == 0 }
208
208
}
209
209
210
210
impl Mutable for SmallIntSet {
Original file line number Diff line number Diff line change @@ -365,7 +365,7 @@ pub fn run_tests_console(opts: &TestOpts,
365
365
fn print_failures(st: &ConsoleTestState) {
366
366
st.out.write_line(" \n failures: ");
367
367
let mut failures = ~[];
368
- for uint::range(0, vec::uniq_len(&const st.failures)) |i| {
368
+ for uint::range(0, st.failures.len( )) |i| {
369
369
let name = copy st.failures[i].name;
370
370
failures.push(name.to_str());
371
371
}
Original file line number Diff line number Diff line change @@ -209,7 +209,7 @@ impl<T: Owned> Peekable<T> for PortSet<T> {
209
209
fn peek ( & self ) -> bool {
210
210
// It'd be nice to use self.port.each, but that version isn't
211
211
// pure.
212
- for uint:: range( 0 , vec :: uniq_len ( & const self. ports) ) |i| {
212
+ for uint:: range( 0 , self . ports. len ( ) ) |i| {
213
213
let port: & pipesy:: Port < T > = & self . ports [ i] ;
214
214
if port. peek ( ) {
215
215
return true ;
Original file line number Diff line number Diff line change @@ -16,10 +16,10 @@ use option::Option;
16
16
/// knowledge known is the number of elements contained within.
17
17
pub trait Container {
18
18
/// Return the number of elements in the container
19
- fn len ( & const self ) -> uint ;
19
+ fn len ( & self ) -> uint ;
20
20
21
21
/// Return true if the container contains no elements
22
- fn is_empty ( & const self ) -> bool ;
22
+ fn is_empty ( & self ) -> bool ;
23
23
}
24
24
25
25
/// A trait to represent mutable containers
Original file line number Diff line number Diff line change @@ -1667,7 +1667,7 @@ impl Writer for BytesWriter {
1667
1667
1668
1668
fn seek ( & self , offset : int , whence : SeekStyle ) {
1669
1669
let pos = * self . pos ;
1670
- let len = vec :: uniq_len ( & const * self . bytes ) ;
1670
+ let len = self . bytes . len ( ) ;
1671
1671
* self . pos = seek_in_buf ( offset, pos, len, whence) ;
1672
1672
}
1673
1673
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ More runtime type reflection
18
18
19
19
use cast:: transmute;
20
20
use char;
21
+ use container:: Container ;
21
22
use intrinsic;
22
23
use intrinsic:: { TyDesc , TyVisitor , visit_tydesc} ;
23
24
use intrinsic:: Opaque ;
@@ -502,7 +503,7 @@ impl TyVisitor for ReprVisitor {
502
503
_offset : uint ,
503
504
inner : * TyDesc )
504
505
-> bool {
505
- match self . var_stk [ vec :: uniq_len ( & const * self . var_stk ) - 1 ] {
506
+ match self . var_stk [ self . var_stk . len ( ) - 1 ] {
506
507
Matched => {
507
508
if i != 0 {
508
509
self . writer . write_str ( ", " ) ;
@@ -520,7 +521,7 @@ impl TyVisitor for ReprVisitor {
520
521
_disr_val : int ,
521
522
n_fields : uint ,
522
523
_name : & str ) -> bool {
523
- match self . var_stk [ vec :: uniq_len ( & const * self . var_stk ) - 1 ] {
524
+ match self . var_stk [ self . var_stk . len ( ) - 1 ] {
524
525
Matched => {
525
526
if n_fields > 0 {
526
527
self . writer . write_char ( ')' ) ;
You can’t perform that action at this time.
0 commit comments