Auto merge of #7776 - frewsxcv:str-join, r=mbrubeck

Avoid allocations when joining strings



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7776)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-09-29 16:59:14 -06:00
commit 4823ec947e
5 changed files with 11 additions and 12 deletions

View file

@ -18,7 +18,7 @@ use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::node::{Node, NodeTypeId};
use dom::virtualmethods::VirtualMethods;
use std::cell::Cell;
use util::str::{DOMString, split_html_space_chars};
use util::str::{DOMString, split_html_space_chars, str_join};
#[dom_struct]
pub struct HTMLOptionElement {
@ -93,8 +93,7 @@ impl HTMLOptionElementMethods for HTMLOptionElement {
let node = NodeCast::from_ref(self);
let mut content = String::new();
collect_text(&node, &mut content);
let v: Vec<&str> = split_html_space_chars(&content).collect();
v.join(" ")
str_join(split_html_space_chars(&content), " ")
}
// https://www.whatwg.org/html/#dom-option-text