From 9d64e46013096997627da62ecc65225bc22682e8 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Thu, 28 Nov 2013 23:52:11 +1100 Subject: std::str: remove from_utf8. This function had type &[u8] -> ~str, i.e. it allocates a string internally, even though the non-allocating version that take &[u8] -> &str and ~[u8] -> ~str are all that is necessary in most circumstances. --- src/libsyntax/print/pprust.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libsyntax/print') diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 9eb61728e59..3c6fa86485d 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -210,7 +210,7 @@ pub fn fun_to_str(decl: &ast::fn_decl, purity: ast::purity, name: ast::Ident, end(s); // Close the head box end(s); // Close the outer box eof(s.s); - str::from_utf8(*wr.inner_ref()) + str::from_utf8_owned(wr.inner_ref().to_owned()) } pub fn block_to_str(blk: &ast::Block, intr: @ident_interner) -> ~str { @@ -222,7 +222,7 @@ pub fn block_to_str(blk: &ast::Block, intr: @ident_interner) -> ~str { ibox(s, 0u); print_block(s, blk); eof(s.s); - str::from_utf8(*wr.inner_ref()) + str::from_utf8_owned(wr.inner_ref().to_owned()) } pub fn meta_item_to_str(mi: &ast::MetaItem, intr: @ident_interner) -> ~str { @@ -2292,7 +2292,7 @@ pub fn to_str(t: &T, f: |@ps, &T|, intr: @ident_interner) -> ~str { let s = rust_printer(wr as @mut io::Writer, intr); f(s, t); eof(s.s); - str::from_utf8(*wr.inner_ref()) + str::from_utf8_owned(wr.inner_ref().to_owned()) } pub fn next_comment(s: @ps) -> Option { -- cgit 1.4.1-3-g733a5