diff options
| author | Marvin Löbel <loebel.marvin@gmail.com> | 2013-03-21 22:59:33 +0100 |
|---|---|---|
| committer | Marvin Löbel <loebel.marvin@gmail.com> | 2013-03-21 23:06:04 +0100 |
| commit | ee2f3d9673407db3ca5a0eb24e01ef52c7fc676c (patch) | |
| tree | f85fe06cfa6bfab47ddfe9c55e9c91c2a67495d6 /src/libsyntax | |
| parent | ed25a674ac6bc53c9ee9f8c1cce21541f6811d4b (diff) | |
| download | rust-ee2f3d9673407db3ca5a0eb24e01ef52c7fc676c.tar.gz rust-ee2f3d9673407db3ca5a0eb24e01ef52c7fc676c.zip | |
Switched over substr and trim functions in str to be non-allocating, temporary renamed them to better track use-sites
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/parse/comments.rs | 11 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer.rs | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index b5072e8c2b5..01a4265ca4d 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -70,10 +70,10 @@ pub fn strip_doc_comment_decoration(comment: &str) -> ~str { /// remove whitespace-only lines from the start/end of lines fn vertical_trim(lines: ~[~str]) -> ~[~str] { let mut i = 0u, j = lines.len(); - while i < j && lines[i].trim().is_empty() { + while i < j && lines[i].trim_DBGBRWD().is_empty() { i += 1u; } - while j > i && lines[j - 1u].trim().is_empty() { + while j > i && lines[j - 1u].trim_DBGBRWD().is_empty() { j -= 1u; } return lines.slice(i, j).to_owned(); @@ -84,7 +84,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> ~str { let mut i = max.get_or_default(uint::max_value); for lines.each |line| { - if line.trim().is_empty() { + if line.trim_DBGBRWD().is_empty() { loop; } for line.each_chari |j, c| { @@ -109,7 +109,10 @@ pub fn strip_doc_comment_decoration(comment: &str) -> ~str { } if comment.starts_with(~"//") { - return comment.slice(3u, comment.len()).trim(); + // FIXME #5475: + // return comment.slice(3u, comment.len()).trim_DBGBRWD().to_owned(); + let r = comment.slice(3u, comment.len()); return r.trim_DBGBRWD().to_owned(); + } if comment.starts_with(~"/*") { diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 6cb4065935c..80be23d40f7 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -262,7 +262,7 @@ fn consume_whitespace_and_comments(rdr: @mut StringReader) } pub pure fn is_line_non_doc_comment(s: &str) -> bool { - s.trim_right().all(|ch| ch == '/') + s.trim_right_DBGBRWD().all(|ch| ch == '/') } // PRECONDITION: rdr.curr is not whitespace |
