about summary refs log tree commit diff
path: root/src/libsyntax/parse/comments.rs
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2013-06-14 01:39:06 +1000
committerHuon Wilson <dbau.pp+github@gmail.com>2013-06-16 10:50:28 +1000
commit4b18fff2be74df9a2db5ee6ab418da322ad6ae18 (patch)
tree80a7b5caf2c7b2d1f6dc455fb725f4138f008f57 /src/libsyntax/parse/comments.rs
parentc989b79127c5062df0a64d8c383de93c82a3d9b7 (diff)
downloadrust-4b18fff2be74df9a2db5ee6ab418da322ad6ae18.tar.gz
rust-4b18fff2be74df9a2db5ee6ab418da322ad6ae18.zip
std: convert str::{map,levdistance,subslice_offset} to methods.
The first two become map_chars and lev_distance. Also, remove a few
allocations in rustdoc.
Diffstat (limited to 'src/libsyntax/parse/comments.rs')
-rw-r--r--src/libsyntax/parse/comments.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index 68473f11537..82a7b55eeee 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -89,12 +89,11 @@ pub fn strip_doc_comment_decoration(comment: &str) -> ~str {
         }
 
         return do lines.map |line| {
-            let mut chars = ~[];
-            for line.iter().advance |c| { chars.push(c) }
+            let chars = line.iter().collect::<~[char]>();
             if i > chars.len() {
                 ~""
             } else {
-                str::from_chars(chars.slice(i, chars.len()).to_owned())
+                str::from_chars(chars.slice(i, chars.len()))
             }
         };
     }
@@ -103,14 +102,13 @@ pub fn strip_doc_comment_decoration(comment: &str) -> ~str {
         // FIXME #5475:
         // return comment.slice(3u, comment.len()).trim().to_owned();
         let r = comment.slice(3u, comment.len()); return r.trim().to_owned();
-
     }
 
     if comment.starts_with("/*") {
-        let mut lines = ~[];
-        for str::each_line_any(comment.slice(3u, comment.len() - 2u)) |line| {
-            lines.push(line.to_owned())
-        }
+        let lines = comment.slice(3u, comment.len() - 2u)
+            .any_line_iter()
+            .transform(|s| s.to_owned())
+            .collect::<~[~str]>();
         let lines = vertical_trim(lines);
         let lines = block_trim(lines, ~"\t ", None);
         let lines = block_trim(lines, ~"*", Some(1u));