Skip to content

Commit ec8ddfe

Browse files
committed
try aarch64 simd jetscii with const new.
1 parent 23c3012 commit ec8ddfe

File tree

7 files changed

+32
-2561
lines changed

7 files changed

+32
-2561
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ arbitrary = { version = "1", optional = true, features = ["derive"] }
4343
bon = { version = "3", optional = true }
4444
caseless = "0.2.1"
4545
fmt2io = { version = "1.0.0", optional = true }
46-
jetscii = "0.5.3"
46+
# jetscii = "0.5.3"
47+
jetscii = { git = "https://github.com/kivikakk/jetscii", branch = "aarch64_simd_const" }
4748

4849
[dev-dependencies]
4950
ntest = "0.9"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bench-all: binaries
5959
benches/samply-bench-input.md:
6060
cat ${ROOT}/vendor/progit/*/*/*.markdown > $@
6161

62-
SAMPLY_OPTIONS:=-r 10000 --iteration-count 20 --reuse-threads
62+
SAMPLY_OPTIONS:=-r 10000 --iteration-count 40 --reuse-threads
6363
SAMPLY_COMRAK_ARGS:=benches/samply-bench-input.md -o /dev/null
6464

6565
samply-comrak-branch: benches/samply-bench-input.md build-comrak-branch

src/html.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,10 +1602,10 @@ fn tagfilter(literal: &str) -> bool {
16021602

16031603
fn tagfilter_block(output: &mut dyn Write, buffer: &str) -> fmt::Result {
16041604
let bytes = buffer.as_bytes();
1605-
let matcher = jetscii::bytes!(b'<');
1605+
const MATCHER: jetscii::BytesConst = jetscii::bytes!(b'<');
16061606

16071607
let mut offset = 0;
1608-
while let Some(i) = matcher.find(&bytes[offset..]) {
1608+
while let Some(i) = MATCHER.find(&bytes[offset..]) {
16091609
output.write_str(&buffer[offset..offset + i])?;
16101610
if tagfilter(&buffer[offset + i..]) {
16111611
output.write_str("&lt;")?;
@@ -1638,10 +1638,10 @@ pub fn dangerous_url(input: &str) -> bool {
16381638
/// URLs in attributes. See escape_href.
16391639
pub fn escape(output: &mut dyn Write, buffer: &str) -> fmt::Result {
16401640
let bytes = buffer.as_bytes();
1641-
let matcher = jetscii::bytes!(b'"', b'&', b'<', b'>');
1641+
const MATCHER: jetscii::BytesConst = jetscii::bytes!(b'"', b'&', b'<', b'>');
16421642

16431643
let mut offset = 0;
1644-
while let Some(i) = matcher.find(&bytes[offset..]) {
1644+
while let Some(i) = MATCHER.find(&bytes[offset..]) {
16451645
let esc: &str = match bytes[offset + i] {
16461646
b'"' => "&quot;",
16471647
b'&' => "&amp;",

src/parser/mod.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,10 +2485,10 @@ where
24852485

24862486
let matches_end_condition = match block_type {
24872487
1 => scanners::html_block_end_1(&line[self.first_nonspace..]),
2488-
2 => scanners::html_block_end_2(&line[self.first_nonspace..]),
2489-
3 => scanners::html_block_end_3(&line[self.first_nonspace..]),
2490-
4 => scanners::html_block_end_4(&line[self.first_nonspace..]),
2491-
5 => scanners::html_block_end_5(&line[self.first_nonspace..]),
2488+
2 => Self::html_block_end_2(&line[self.first_nonspace..]),
2489+
3 => Self::html_block_end_3(&line[self.first_nonspace..]),
2490+
4 => Self::html_block_end_4(&line[self.first_nonspace..]),
2491+
5 => Self::html_block_end_5(&line[self.first_nonspace..]),
24922492
_ => false,
24932493
};
24942494

@@ -2543,6 +2543,26 @@ where
25432543
}
25442544
}
25452545

2546+
fn html_block_end_2(buf: &str) -> bool {
2547+
const MATCHER: jetscii::Substring = jetscii::Substring::new("-->");
2548+
MATCHER.find(buf).is_some()
2549+
}
2550+
2551+
fn html_block_end_3(buf: &str) -> bool {
2552+
const MATCHER: jetscii::Substring = jetscii::Substring::new("?>");
2553+
MATCHER.find(buf).is_some()
2554+
}
2555+
2556+
fn html_block_end_4(buf: &str) -> bool {
2557+
const MATCHER: jetscii::BytesConst = jetscii::bytes!('>');
2558+
MATCHER.find(buf.as_bytes()).is_some()
2559+
}
2560+
2561+
fn html_block_end_5(buf: &str) -> bool {
2562+
const MATCHER: jetscii::Substring = jetscii::Substring::new("]]>");
2563+
MATCHER.find(buf).is_some()
2564+
}
2565+
25462566
fn add_line(&mut self, node: Node<'a>, line: &str) {
25472567
let mut ast = node.data.borrow_mut();
25482568
assert!(ast.open);

src/scanners.re

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -82,46 +82,6 @@ pub fn html_block_end_1(s: &str) -> bool {
8282
*/
8383
}
8484

85-
pub fn html_block_end_2(s: &str) -> bool {
86-
let mut cursor = 0;
87-
let mut marker = 0;
88-
let len = s.len();
89-
/*!re2c
90-
[^\n\x00]* '-->' { return true; }
91-
* { return false; }
92-
*/
93-
}
94-
95-
pub fn html_block_end_3(s: &str) -> bool {
96-
let mut cursor = 0;
97-
let mut marker = 0;
98-
let len = s.len();
99-
/*!re2c
100-
[^\n\x00]* '?>' { return true; }
101-
* { return false; }
102-
*/
103-
}
104-
105-
pub fn html_block_end_4(s: &str) -> bool {
106-
let mut cursor = 0;
107-
let mut marker = 0;
108-
let len = s.len();
109-
/*!re2c
110-
[^\n\x00]* '>' { return true; }
111-
* { return false; }
112-
*/
113-
}
114-
115-
pub fn html_block_end_5(s: &str) -> bool {
116-
let mut cursor = 0;
117-
let mut marker = 0;
118-
let len = s.len();
119-
/*!re2c
120-
[^\n\x00]* ']]>' { return true; }
121-
* { return false; }
122-
*/
123-
}
124-
12585
pub fn alert_start(s: &str) -> Option<AlertType> {
12686
let mut cursor = 0;
12787
let mut marker = 0;

0 commit comments

Comments
 (0)