Skip to content

Commit 3ed3712

Browse files
committed
Revert unescape strategy testing and benchmarks.
1 parent 7c46b96 commit 3ed3712

File tree

1,834 files changed

+332678
-122856
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,834 files changed

+332678
-122856
lines changed

Cargo.lock

Lines changed: 0 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ rustdoc-args = ["--cfg", "docsrs"]
2121
default = []
2222
unescape = ["_unescape_either", "dep:hashify", "dep:serde_json"]
2323
unescape_fast = ["_unescape_either", "dep:matchgen", "dep:serde_json"]
24-
unescape_phf = ["_unescape_either", "entities"]
25-
unescape_quick = ["_unescape_either", "entities_quick"]
2624
entities = ["dep:phf", "dep:phf_codegen", "dep:serde_json"]
27-
entities_quick = ["dep:quickphf", "dep:quickphf_codegen", "dep:serde_json"]
2825
# Enable iai benchmarks
2926
iai = []
3027
# Make internal functions like unescape_fast public for benchmarks.
@@ -36,15 +33,13 @@ _unescape_either = []
3633
matchgen = { version = "0.4.0", optional = true }
3734
phf = { version = "0.11.1", default-features = false, optional = true }
3835
phf_codegen = { version = "0.11.1", optional = true }
39-
quickphf_codegen = { git = "https://github.com/AlexTMjugador/quickphf.git", branch = "feat/support-array-key-vals", optional = true }
4036
serde_json = { version = "1.0", optional = true }
4137

4238
[dependencies]
4339
hashify = { version = "0.2.6", optional = true }
4440
memchr = "2.5.0"
4541
pastey = "0.1.0"
4642
phf = { version = "0.11.1", default-features = false, optional = true }
47-
quickphf = { git = "https://github.com/AlexTMjugador/quickphf.git", branch = "feat/support-array-key-vals", optional = true }
4843

4944
[dev-dependencies]
5045
assert2 = "0.3.7"
@@ -73,11 +68,6 @@ name = "unescape"
7368
harness = false
7469
required-features = ["bench", "_unescape_either"]
7570

76-
[[bench]]
77-
name = "hash"
78-
harness = false
79-
required-features = ["bench", "unescape", "unescape_phf", "unescape_quick", "unescape_fast"]
80-
8171
[lints]
8272
workspace = true
8373

benches/hash.rs

Lines changed: 0 additions & 49 deletions
This file was deleted.

benches/unescape.rs

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,8 @@ fn benchmarks(c: &mut Criterion) {
4545
#[cfg(feature = "unescape")]
4646
util::benchmark_name!(
4747
group,
48-
"hashify",
49-
(Map::<Hashify>::default(), ContextGeneral),
50-
&name,
51-
&input
52-
);
53-
54-
#[cfg(feature = "unescape_phf")]
55-
util::benchmark_name!(
56-
group,
57-
"phf",
58-
(Map::<PhfMap>::default(), ContextGeneral),
59-
&name,
60-
&input
61-
);
62-
63-
#[cfg(feature = "unescape_quick")]
64-
util::benchmark_name!(
65-
group,
66-
"quickphf",
67-
(Map::<QuickPhf>::default(), ContextGeneral),
48+
"map",
49+
(Map, ContextGeneral),
6850
&name,
6951
&input
7052
);
@@ -87,26 +69,8 @@ fn benchmarks(c: &mut Criterion) {
8769
#[cfg(feature = "unescape")]
8870
util::benchmark_name!(
8971
group,
90-
"hashify",
91-
(Map::<Hashify>::default(), ContextAttribute),
92-
&name,
93-
&input
94-
);
95-
96-
#[cfg(feature = "unescape_phf")]
97-
util::benchmark_name!(
98-
group,
99-
"phf",
100-
(Map::<PhfMap>::default(), ContextAttribute),
101-
&name,
102-
&input
103-
);
104-
105-
#[cfg(feature = "unescape_quick")]
106-
util::benchmark_name!(
107-
group,
108-
"quickphf",
109-
(Map::<QuickPhf>::default(), ContextAttribute),
72+
"map",
73+
(Map, ContextAttribute),
11074
&name,
11175
&input
11276
);

benches/unescape_iai.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ macro_rules! iai_benchmarks {
1616
$(
1717
#[cfg(feature = "unescape")]
1818
fn [<iai_map_unescape_ $name>]() -> Cow<'static, str> {
19-
unescape_in((Map::<PhfMap>::default(), ContextGeneral), black_box($input))
19+
unescape_in((Map, ContextGeneral), black_box($input))
2020
}
2121

2222
#[cfg(feature = "unescape")]
2323
fn [<iai_map_unescape_attribute_ $name>]() -> Cow<'static, str> {
24-
unescape_in((Map::<PhfMap>::default(), ContextAttribute), black_box($input))
24+
unescape_in((Map, ContextAttribute), black_box($input))
2525
}
2626

2727
#[cfg(feature = "unescape_fast")]

build.rs

Lines changed: 2 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ fn main() {
1414
#[cfg(any(
1515
feature = "unescape_fast",
1616
feature = "unescape",
17-
feature = "entities",
18-
feature = "entities_quick"
17+
feature = "entities"
1918
))]
2019
let entities = load_entities("entities.json");
2120

@@ -30,9 +29,6 @@ fn main() {
3029

3130
#[cfg(feature = "entities")]
3231
generate_entities_rs(&entities);
33-
34-
#[cfg(feature = "entities_quick")]
35-
generate_entities_quick_rs(&entities);
3632
}
3733

3834
/// Generate entities.rs file containing all valid HTML entities in a
@@ -98,72 +94,6 @@ fn generate_entities_rs(entities: &[(String, String)]) {
9894
.unwrap();
9995
}
10096

101-
/// Generate `entities_quick.rs` file containing all valid HTML entities in a
102-
/// [`quickphf::PhfMap`]. It also generates documentation with a table of all
103-
/// the entities and their expansions.
104-
#[cfg(feature = "entities_quick")]
105-
fn generate_entities_quick_rs(entities: &[(String, String)]) {
106-
use std::env;
107-
use std::fs::File;
108-
use std::io::{BufWriter, Write};
109-
use std::path::Path;
110-
111-
let out_path =
112-
Path::new(&env::var("OUT_DIR").unwrap()).join("entities_quick.rs");
113-
let mut out = BufWriter::new(File::create(out_path).unwrap());
114-
115-
writeln!(out, "\
116-
/// A map of all valid HTML entities to their expansions.\n\
117-
///\n\
118-
/// The keys of the map are full entity byte strings, e.g. `b\"&copy;\"`, and the\n\
119-
/// values are their expansions, e.g. `b\"©\"`.\n\
120-
///\n\
121-
/// See the [WHATWG HTML spec][spec] for the canonical list of entities with\n\
122-
/// their codepoints and glyphs. The [entities.json][] file linked there is\n\
123-
/// used to generate this constant.\n\
124-
///\n\
125-
/// [spec]: https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references\n\
126-
/// [entities.json]: https://html.spec.whatwg.org/entities.json\n\
127-
///\n\
128-
/// Entity | Codepoints | Glyph\n\
129-
/// -------------------------------|--------------------|------").unwrap();
130-
131-
let (keys, values): (Vec<_>, Vec<_>) = entities
132-
.iter()
133-
.inspect(|(name, glyph)| {
134-
// `{:28}` would pad the output inside the backticks.
135-
let name = format!("`{name}`");
136-
137-
let codepoints = glyph
138-
.chars()
139-
.map(|c| format!("U+{:06X}", u32::from(c)))
140-
.collect::<Vec<_>>()
141-
.join(", ");
142-
143-
// Suppress a few inconvenient glyphs. Newline adds an extra line, and
144-
// tab causes a clippy warning. Backticks are actually fine, but it’s
145-
// correct to escape them.
146-
let glyph = match glyph.as_str() {
147-
"\n" | "\t" => "",
148-
"`" => "\\`",
149-
v => v,
150-
};
151-
152-
writeln!(out, "/// {name:30} | {codepoints:18} | {glyph}",)
153-
.unwrap();
154-
})
155-
.map(|(name, glyph)| (name.as_bytes(), glyph.as_bytes()))
156-
.unzip();
157-
158-
writeln!(out, "#[allow(clippy::unreadable_literal)]").unwrap();
159-
writeln!(
160-
out,
161-
"pub static ENTITIES_QUICK: quickphf::PhfMap<&[u8], &[u8]> = {};",
162-
quickphf_codegen::build_map(&keys, &values),
163-
)
164-
.unwrap();
165-
}
166-
16797
/// Generate `entities_length.rs` file containing constants with the minimum
16898
/// and maximum entity lengths.
16999
#[cfg(any(feature = "unescape", feature = "entities"))]
@@ -222,7 +152,7 @@ fn generate_unescape_entity_rs(entities: &[(String, String)]) {
222152
/// Get expansion or `None` for a candidate HTML entity byte string.\n\
223153
#[must_use]\n\
224154
#[allow(clippy::too_many_lines)]\n\
225-
fn expand_entity(candidate: &[u8]) -> Option<&'static [u8]> {{\n\
155+
fn expand_entity(candidate: &[u8]) -> Option<&[u8]> {{\n\
226156
hashify::map! {{\n\
227157
candidate,\n\
228158
&[u8],"

src/lib.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,3 @@ feature! {
153153
}
154154
pub use entities::*;
155155
}
156-
157-
feature! {
158-
#![feature = "entities_quick"]
159-
160-
/// For some reason `rustdoc` doesn’t show the feature flags without `mod`.
161-
mod entities_quick {
162-
include!(concat!(env!("OUT_DIR"), "/entities_quick.rs"));
163-
}
164-
pub use entities_quick::*;
165-
}

0 commit comments

Comments
 (0)