diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-06-18 09:39:16 -0700 |
|---|---|---|
| committer | Corey Richardson <corey@octayn.net> | 2013-06-28 10:44:16 -0400 |
| commit | e015bee2866a802f17c84bd6d3a06212945a9d17 (patch) | |
| tree | 676f45de5bbcc9420fb0417719b262953c8d808c /src/libstd | |
| parent | 89eb9951958dc2cd652645cea5badf4bb9edc6f9 (diff) | |
| download | rust-e015bee2866a802f17c84bd6d3a06212945a9d17.tar.gz rust-e015bee2866a802f17c84bd6d3a06212945a9d17.zip | |
Rewrite each_path to allow performance improvements in the future.
Instead of determining paths from the path tag, we iterate through modules' children recursively in the metadata. This will allow for lazy external module resolution.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/char.rs | 1 | ||||
| -rw-r--r-- | src/libstd/os.rs | 6 | ||||
| -rw-r--r-- | src/libstd/rand.rs | 1 | ||||
| -rw-r--r-- | src/libstd/str.rs | 21 | ||||
| -rw-r--r-- | src/libstd/unstable/extfmt.rs | 1 |
5 files changed, 19 insertions, 11 deletions
diff --git a/src/libstd/char.rs b/src/libstd/char.rs index 797fd9e8c02..8f0870af513 100644 --- a/src/libstd/char.rs +++ b/src/libstd/char.rs @@ -10,6 +10,7 @@ //! Utilities for manipulating the char type +use container::Container; use option::{None, Option, Some}; use str; use str::{StrSlice, OwnedStr}; diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 7d848184493..590292d0d32 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -29,6 +29,7 @@ #[allow(missing_doc)]; use cast; +use container::Container; use io; use iterator::IteratorUtil; use libc; @@ -1500,7 +1501,10 @@ mod tests { fn test_getenv_big() { let mut s = ~""; let mut i = 0; - while i < 100 { s += "aaaaaaaaaa"; i += 1; } + while i < 100 { + s = s + "aaaaaaaaaa"; + i += 1; + } let n = make_rand_name(); setenv(n, s); debug!(copy s); diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs index 8a6c05ce6e2..5baff8aee68 100644 --- a/src/libstd/rand.rs +++ b/src/libstd/rand.rs @@ -42,6 +42,7 @@ fn main () { use cast; use cmp; +use container::Container; use int; use iterator::IteratorUtil; use local_data; diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 3c512d9bfd2..2144afc0fbd 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -1140,6 +1140,17 @@ impl<'self> Str for @str { } } +impl<'self> Container for &'self str { + #[inline] + fn len(&self) -> uint { + do as_buf(*self) |_p, n| { n - 1u } + } + #[inline] + fn is_empty(&self) -> bool { + self.len() == 0 + } +} + #[allow(missing_doc)] pub trait StrSlice<'self> { fn contains<'a>(&self, needle: &'a str) -> bool; @@ -1158,10 +1169,8 @@ pub trait StrSlice<'self> { fn any_line_iter(&self) -> AnyLineIterator<'self>; fn word_iter(&self) -> WordIterator<'self>; fn ends_with(&self, needle: &str) -> bool; - fn is_empty(&self) -> bool; fn is_whitespace(&self) -> bool; fn is_alphanumeric(&self) -> bool; - fn len(&self) -> uint; fn char_len(&self) -> uint; fn slice(&self, begin: uint, end: uint) -> &'self str; @@ -1362,9 +1371,6 @@ impl<'self> StrSlice<'self> for &'self str { self.split_iter(char::is_whitespace).filter(|s| !s.is_empty()) } - /// Returns true if the string has length 0 - #[inline] - fn is_empty(&self) -> bool { self.len() == 0 } /** * Returns true if the string contains only whitespace * @@ -1379,11 +1385,6 @@ impl<'self> StrSlice<'self> for &'self str { */ #[inline] fn is_alphanumeric(&self) -> bool { self.iter().all(char::is_alphanumeric) } - /// Returns the size in bytes not counting the null terminator - #[inline] - fn len(&self) -> uint { - do as_buf(*self) |_p, n| { n - 1u } - } /// Returns the number of characters that a string holds #[inline] fn char_len(&self) -> uint { self.iter().len_() } diff --git a/src/libstd/unstable/extfmt.rs b/src/libstd/unstable/extfmt.rs index 87bd25bdad3..624062a7ec4 100644 --- a/src/libstd/unstable/extfmt.rs +++ b/src/libstd/unstable/extfmt.rs @@ -94,6 +94,7 @@ use iterator::IteratorUtil; #[doc(hidden)] pub mod ct { use char; + use container::Container; use prelude::*; use str; |
