diff options
| author | Seo Sanghyeon <sanxiyn@gmail.com> | 2013-05-21 22:55:07 +0900 |
|---|---|---|
| committer | Seo Sanghyeon <sanxiyn@gmail.com> | 2013-05-21 22:55:07 +0900 |
| commit | d543354d6c56e8962b0c03397d43df3f16b07d03 (patch) | |
| tree | 18a4f7d7761538e27d26c01f2cacd64f397297ba | |
| parent | 5a3e3205144969fe9a9ec724929d641f309a6162 (diff) | |
| download | rust-d543354d6c56e8962b0c03397d43df3f16b07d03.tar.gz rust-d543354d6c56e8962b0c03397d43df3f16b07d03.zip | |
Remove unnecessary allocations flagged by lint from rustdoc
| -rw-r--r-- | src/librustdoc/attr_parser.rs | 6 | ||||
| -rw-r--r-- | src/librustdoc/config.rs | 8 | ||||
| -rw-r--r-- | src/librustdoc/desc_to_brief_pass.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/escape_pass.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/markdown_index_pass.rs | 36 | ||||
| -rw-r--r-- | src/librustdoc/markdown_pass.rs | 6 | ||||
| -rw-r--r-- | src/librustdoc/markdown_writer.rs | 6 | ||||
| -rw-r--r-- | src/librustdoc/sectionalize_pass.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/unindent_pass.rs | 2 |
9 files changed, 36 insertions, 36 deletions
diff --git a/src/librustdoc/attr_parser.rs b/src/librustdoc/attr_parser.rs index 433809b9db2..ec31795337b 100644 --- a/src/librustdoc/attr_parser.rs +++ b/src/librustdoc/attr_parser.rs @@ -26,7 +26,7 @@ fn doc_metas( attrs: ~[ast::attribute] ) -> ~[@ast::meta_item] { - let doc_attrs = attr::find_attrs_by_name(attrs, ~"doc"); + let doc_attrs = attr::find_attrs_by_name(attrs, "doc"); let doc_metas = do doc_attrs.map |attr| { attr::attr_meta(attr::desugar_doc_attr(attr)) }; @@ -36,7 +36,7 @@ fn doc_metas( pub fn parse_crate(attrs: ~[ast::attribute]) -> CrateAttrs { let link_metas = attr::find_linkage_metas(attrs); - let name = attr::last_meta_item_value_str_by_name(link_metas, ~"name"); + let name = attr::last_meta_item_value_str_by_name(link_metas, "name"); CrateAttrs { name: name.map(|s| copy **s) @@ -58,7 +58,7 @@ pub fn parse_hidden(attrs: ~[ast::attribute]) -> bool { do doc_metas(attrs).find |meta| { match attr::get_meta_item_list(*meta) { Some(metas) => { - let hiddens = attr::find_meta_items_by_name(metas, ~"hidden"); + let hiddens = attr::find_meta_items_by_name(metas, "hidden"); !hiddens.is_empty() } None => false diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 0644b57a0f4..7464b708045 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -70,12 +70,12 @@ fn opts() -> ~[(getopts::Opt, ~str)] { pub fn usage() { use core::io::println; - println(~"Usage: rustdoc [options] <cratefile>\n"); - println(~"Options:\n"); + println("Usage: rustdoc [options] <cratefile>\n"); + println("Options:\n"); for opts().each |opt| { println(fmt!(" %s", opt.second())); } - println(~""); + println(""); } pub fn default_config(input_crate: &Path) -> Config { @@ -227,7 +227,7 @@ pub fn maybe_find_pandoc( }; let pandoc = do vec::find(possible_pandocs) |pandoc| { - let output = program_output(*pandoc, ~[~"--version"]); + let output = program_output(*pandoc, [~"--version"]); debug!("testing pandoc cmd %s: %?", *pandoc, output); output.status == 0 }; diff --git a/src/librustdoc/desc_to_brief_pass.rs b/src/librustdoc/desc_to_brief_pass.rs index c25764ab060..c61b38743fd 100644 --- a/src/librustdoc/desc_to_brief_pass.rs +++ b/src/librustdoc/desc_to_brief_pass.rs @@ -104,7 +104,7 @@ fn first_sentence(s: ~str) -> Option<~str> { let paras = paragraphs(s); if !paras.is_empty() { let first_para = paras.head(); - Some(str::replace(first_sentence_(*first_para), ~"\n", ~" ")) + Some(str::replace(first_sentence_(*first_para), "\n", " ")) } else { None } @@ -132,7 +132,7 @@ fn first_sentence_(s: &str) -> ~str { str::to_owned(str::slice(s, 0, idx - 1)) } _ => { - if str::ends_with(s, ~".") { + if str::ends_with(s, ".") { str::to_owned(s) } else { str::to_owned(s) diff --git a/src/librustdoc/escape_pass.rs b/src/librustdoc/escape_pass.rs index 11e9b71afdf..045e916b110 100644 --- a/src/librustdoc/escape_pass.rs +++ b/src/librustdoc/escape_pass.rs @@ -20,7 +20,7 @@ pub fn mk_pass() -> Pass { } fn escape(s: &str) -> ~str { - str::replace(s, ~"\\", ~"\\\\") + str::replace(s, "\\", "\\\\") } #[test] diff --git a/src/librustdoc/markdown_index_pass.rs b/src/librustdoc/markdown_index_pass.rs index 2c34f3543b7..c7329c4a54b 100644 --- a/src/librustdoc/markdown_index_pass.rs +++ b/src/librustdoc/markdown_index_pass.rs @@ -124,24 +124,24 @@ pub fn pandoc_header_id(header: &str) -> ~str { return header; fn remove_formatting(s: &str) -> ~str { - str::replace(s, ~"`", ~"") + str::replace(s, "`", "") } fn remove_punctuation(s: &str) -> ~str { - let s = str::replace(s, ~"<", ~""); - let s = str::replace(s, ~">", ~""); - let s = str::replace(s, ~"[", ~""); - let s = str::replace(s, ~"]", ~""); - let s = str::replace(s, ~"(", ~""); - let s = str::replace(s, ~")", ~""); - let s = str::replace(s, ~"@~", ~""); - let s = str::replace(s, ~"~", ~""); - let s = str::replace(s, ~"/", ~""); - let s = str::replace(s, ~":", ~""); - let s = str::replace(s, ~"&", ~""); - let s = str::replace(s, ~"^", ~""); - let s = str::replace(s, ~",", ~""); - let s = str::replace(s, ~"'", ~""); - let s = str::replace(s, ~"+", ~""); + let s = str::replace(s, "<", ""); + let s = str::replace(s, ">", ""); + let s = str::replace(s, "[", ""); + let s = str::replace(s, "]", ""); + let s = str::replace(s, "(", ""); + let s = str::replace(s, ")", ""); + let s = str::replace(s, "@~", ""); + let s = str::replace(s, "~", ""); + let s = str::replace(s, "/", ""); + let s = str::replace(s, ":", ""); + let s = str::replace(s, "&", ""); + let s = str::replace(s, "^", ""); + let s = str::replace(s, ",", ""); + let s = str::replace(s, "'", ""); + let s = str::replace(s, "+", ""); return s; } fn replace_with_hyphens(s: &str) -> ~str { @@ -149,8 +149,8 @@ pub fn pandoc_header_id(header: &str) -> ~str { // XXX: Hacky implementation here that only covers // one or two spaces. let s = str::trim(s); - let s = str::replace(s, ~" ", ~"-"); - let s = str::replace(s, ~" ", ~"-"); + let s = str::replace(s, " ", "-"); + let s = str::replace(s, " ", "-"); return s; } // FIXME: #4318 Instead of to_ascii and to_str_ascii, could use diff --git a/src/librustdoc/markdown_pass.rs b/src/librustdoc/markdown_pass.rs index 1eac09ea205..4f4bb4194a8 100644 --- a/src/librustdoc/markdown_pass.rs +++ b/src/librustdoc/markdown_pass.rs @@ -110,7 +110,7 @@ fn make_title(page: doc::Page) -> ~str { } }; let title = markdown_pass::header_text(item); - let title = str::replace(title, ~"`", ~""); + let title = str::replace(title, "`", ""); return title; } @@ -169,7 +169,7 @@ pub fn header_kind(doc: doc::ItemTag) -> ~str { } pub fn header_name(doc: doc::ItemTag) -> ~str { - let fullpath = str::connect(doc.path() + ~[doc.name()], ~"::"); + let fullpath = str::connect(doc.path() + ~[doc.name()], "::"); match &doc { &doc::ModTag(_) if doc.id() != syntax::ast::crate_node_id => { fullpath @@ -471,7 +471,7 @@ fn write_methods(ctxt: &Ctxt, docs: &[doc::MethodDoc]) { } fn write_method(ctxt: &Ctxt, doc: doc::MethodDoc) { - write_header_(ctxt, H3, header_text_(~"Method", doc.name)); + write_header_(ctxt, H3, header_text_("Method", doc.name)); write_fnlike( ctxt, copy doc.sig, diff --git a/src/librustdoc/markdown_writer.rs b/src/librustdoc/markdown_writer.rs index 94372127a22..671364f4dbb 100644 --- a/src/librustdoc/markdown_writer.rs +++ b/src/librustdoc/markdown_writer.rs @@ -101,7 +101,7 @@ fn pandoc_writer( use core::io::WriterUtil; debug!("pandoc cmd: %s", pandoc_cmd); - debug!("pandoc args: %s", str::connect(pandoc_args, ~" ")); + debug!("pandoc args: %s", str::connect(pandoc_args, " ")); let pipe_in = os::pipe(); let pipe_out = os::pipe(); @@ -198,7 +198,7 @@ pub fn make_filename( } } doc::ItemPage(doc) => { - str::connect(doc.path() + ~[doc.name()], ~"_") + str::connect(doc.path() + ~[doc.name()], "_") } } }; @@ -213,7 +213,7 @@ pub fn make_filename( fn write_file(path: &Path, s: ~str) { use core::io::WriterUtil; - match io::file_writer(path, ~[io::Create, io::Truncate]) { + match io::file_writer(path, [io::Create, io::Truncate]) { result::Ok(writer) => { writer.write_str(s); } diff --git a/src/librustdoc/sectionalize_pass.rs b/src/librustdoc/sectionalize_pass.rs index 8c3704d55c7..afd29ab7248 100644 --- a/src/librustdoc/sectionalize_pass.rs +++ b/src/librustdoc/sectionalize_pass.rs @@ -149,7 +149,7 @@ fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) { } fn parse_header(line: ~str) -> Option<~str> { - if str::starts_with(line, ~"# ") { + if str::starts_with(line, "# ") { Some(str::slice(line, 2u, str::len(line)).to_owned()) } else { None diff --git a/src/librustdoc/unindent_pass.rs b/src/librustdoc/unindent_pass.rs index 826012a2447..1e3e4acce05 100644 --- a/src/librustdoc/unindent_pass.rs +++ b/src/librustdoc/unindent_pass.rs @@ -82,7 +82,7 @@ fn unindent(s: &str) -> ~str { str::slice(*line, min_indent, str::len(*line)).to_owned() } }; - str::connect(unindented, ~"\n") + str::connect(unindented, "\n") } else { s.to_str() } |
