mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Remove some unnecessary uses of as_slice
For the majority of these cases, `as_slice` can be removed due to `Deref`. In particular, `Deref` for: * `String` -> `str` * `Atom` -> `str` The latter of those two requires, a bump of the locked `string-cache` library
This commit is contained in:
parent
b8ea10bfe3
commit
d838fcce30
19 changed files with 98 additions and 102 deletions
|
@ -94,7 +94,7 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> {
|
|||
|
||||
// http://dom.spec.whatwg.org/#dom-domtokenlist-contains
|
||||
fn Contains(self, token: DOMString) -> Fallible<bool> {
|
||||
self.check_token_exceptions(token.as_slice()).map(|token| {
|
||||
self.check_token_exceptions(&token).map(|token| {
|
||||
self.attribute().root().map(|attr| {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attr = attr.r();
|
||||
|
@ -112,7 +112,7 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> {
|
|||
let element = self.element.root();
|
||||
let mut atoms = element.r().get_tokenlist_attribute(&self.local_name);
|
||||
for token in tokens.iter() {
|
||||
let token = try!(self.check_token_exceptions(token.as_slice()));
|
||||
let token = try!(self.check_token_exceptions(&token));
|
||||
if !atoms.iter().any(|atom| *atom == token) {
|
||||
atoms.push(token);
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> {
|
|||
let element = self.element.root();
|
||||
let mut atoms = element.r().get_tokenlist_attribute(&self.local_name);
|
||||
for token in tokens.iter() {
|
||||
let token = try!(self.check_token_exceptions(token.as_slice()));
|
||||
let token = try!(self.check_token_exceptions(&token));
|
||||
atoms.iter().position(|atom| *atom == token).map(|index| {
|
||||
atoms.remove(index)
|
||||
});
|
||||
|
@ -139,7 +139,7 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> {
|
|||
fn Toggle(self, token: DOMString, force: Option<bool>) -> Fallible<bool> {
|
||||
let element = self.element.root();
|
||||
let mut atoms = element.r().get_tokenlist_attribute(&self.local_name);
|
||||
let token = try!(self.check_token_exceptions(token.as_slice()));
|
||||
let token = try!(self.check_token_exceptions(&token));
|
||||
match atoms.iter().position(|atom| *atom == token) {
|
||||
Some(index) => match force {
|
||||
Some(true) => Ok(true),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue