Skip to content

Commit 914d6ff

Browse files
committed
Improve resourceprep ASCII matching
The two expressions are equivalent, but the new one decreases the time spent parsing full JIDs by 1.2%..11.6% depending on the size of their resource.
1 parent 8e055c4 commit 914d6ff

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ fn prohibited_node_character(c: char) -> bool {
246246
pub fn resourceprep(s: &str) -> Result<Cow<'_, str>, Error> {
247247
// fast path for ascii text
248248
if s.chars()
249-
.all(|c| c.is_ascii() && !tables::ascii_control_character(c))
249+
.all(|c| matches!(c, ' '..='~'))
250250
{
251251
return Ok(Cow::Borrowed(s));
252252
}

0 commit comments

Comments
 (0)