Skip to content

Commit 3bc6364

Browse files
committed
Switch to string-cache for string interning
1 parent 06325bb commit 3bc6364

File tree

22 files changed

+52
-1423
lines changed

22 files changed

+52
-1423
lines changed

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ git = "https://github.com/sfackler/rust-phf"
99
[dependencies.phf_mac]
1010
git = "https://github.com/sfackler/rust-phf"
1111

12+
[dependencies.string_cache]
13+
git = "https://github.com/servo/string-cache"
14+
[dependencies.string_cache_macros]
15+
git = "https://github.com/servo/string-cache"
16+
1217
[dependencies.html5ever-macros]
1318
path = "macros"
1419

examples/noop-tree-builder.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// except according to those terms.
99

1010
extern crate debug;
11+
extern crate string_cache;
1112

1213
extern crate html5ever;
1314

@@ -16,8 +17,9 @@ use std::default::Default;
1617
use std::string::String;
1718
use std::collections::hashmap::HashMap;
1819
use std::str::MaybeOwned;
20+
use string_cache::Atom;
1921

20-
use html5ever::{Namespace, Atom, parse_to, one_input};
22+
use html5ever::{Namespace, parse_to, one_input};
2123
use html5ever::tokenizer::Attribute;
2224
use html5ever::tree_builder::{TreeSink, QuirksMode, NodeOrText};
2325

examples/print-rcdom.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn walk(indent: uint, handle: Handle) {
3939
Element(ref name, ref attrs) => {
4040
print!("<{:s}", name.as_slice());
4141
for attr in attrs.iter() {
42-
print!(" {:s}=\"{:s}\"", attr.name.name, attr.value);
42+
print!(" {:s}=\"{:s}\"", attr.name.name.as_slice(), attr.value);
4343
}
4444
println!(">");
4545
}

examples/print-tree-actions.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// except according to those terms.
99

1010
extern crate debug;
11+
extern crate string_cache;
1112

1213
extern crate html5ever;
1314

@@ -16,8 +17,9 @@ use std::default::Default;
1617
use std::string::String;
1718
use std::collections::hashmap::HashMap;
1819
use std::str::MaybeOwned;
20+
use string_cache::Atom;
1921

20-
use html5ever::{Namespace, Atom, parse_to, one_input};
22+
use html5ever::{Namespace, parse_to, one_input};
2123
use html5ever::tokenizer::Attribute;
2224
use html5ever::tree_builder::{TreeSink, QuirksMode, NodeOrText, AppendNode, AppendText};
2325

@@ -57,7 +59,7 @@ impl TreeSink<uint> for Sink {
5759

5860
fn create_element(&mut self, ns: Namespace, name: Atom, _attrs: Vec<Attribute>) -> uint {
5961
let id = self.get_id();
60-
println!("Created {:?}:{:s} as {:u}", ns, name, id);
62+
println!("Created {:?}:{:s} as {:u}", ns, name.as_slice(), id);
6163
self.names.insert(id, (ns, name));
6264
id
6365
}

examples/tokenize.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ impl TokenSink for TokenPrinter {
5252
self.is_char(false);
5353
// This is not proper HTML serialization, of course.
5454
match tag.kind {
55-
StartTag => print!("TAG : <\x1b[32m{:s}\x1b[0m", tag.name),
56-
EndTag => print!("TAG : <\x1b[31m/{:s}\x1b[0m", tag.name),
55+
StartTag => print!("TAG : <\x1b[32m{:s}\x1b[0m", tag.name.as_slice()),
56+
EndTag => print!("TAG : <\x1b[31m/{:s}\x1b[0m", tag.name.as_slice()),
5757
}
5858
for attr in tag.attrs.iter() {
59-
print!(" \x1b[36m{:s}\x1b[0m='\x1b[34m{:s}\x1b[0m'", attr.name, attr.value);
59+
print!(" \x1b[36m{:s}\x1b[0m='\x1b[34m{:s}\x1b[0m'",
60+
attr.name.name.as_slice(), attr.value);
6061
}
6162
if tag.self_closing {
6263
print!(" \x1b[31m/\x1b[0m");

0 commit comments

Comments
 (0)