Added in-place mutation to DOMString.

The methods which are currently implemented are the ones on String that are currently being used:
string.push_str(...), string.clear() and string.extend(...). We may want to revisit this API.
This commit is contained in:
Alan Jeffrey 2015-11-11 17:30:23 -06:00
parent 034769f280
commit 5db67b5981
5 changed files with 23 additions and 5 deletions

View file

@ -186,6 +186,7 @@ impl<T: ClipboardProvider> TextInput<T> {
vec!(insert)
};
// FIXME(ajeffrey): effecient append for DOMStrings
let mut new_line = prefix.to_owned();
new_line.push_str(&insert_lines[0]);
insert_lines[0] = DOMString::from(new_line);
@ -194,7 +195,8 @@ impl<T: ClipboardProvider> TextInput<T> {
self.edit_point.index = insert_lines[last_insert_lines_index].len();
self.edit_point.line = begin.line + last_insert_lines_index;
insert_lines[last_insert_lines_index].0.push_str(suffix);
// FIXME(ajeffrey): effecient append for DOMStrings
insert_lines[last_insert_lines_index].push_str(suffix);
let mut new_lines = vec!();
new_lines.push_all(lines_prefix);