Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,9 @@ html5ever = { version = "0.35.0", path = "html5ever" }
encoding = "0.2"
encoding_rs = "0.8.12"
log = "0.4"
mac = "0.1"
new_debug_unreachable = "1.0.2"
phf = "0.13"
phf_codegen = "0.13"
proc-macro2 = "1"
quote = "1"
syn = { version = "2", features = ["full"] }
string_cache = "0.9.0"
string_cache_codegen = "0.6.1"
utf-8 = "0.7"
Expand Down
1 change: 0 additions & 1 deletion tendril/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ edition = "2015"
[dependencies]
encoding = { workspace = true, optional = true}
encoding_rs = { workspace = true, optional = true}
mac = { workspace = true }
new_debug_unreachable = { workspace = true }
utf-8 = { workspace = true }

Expand Down
4 changes: 3 additions & 1 deletion tendril/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@ unsafe impl Format for WTF8 {
let mut i = 0;
let mut prev_lead = false;
while i < buf.len() {
let codept = unwrap_or_return!(futf::classify(buf, i), false);
let Some(codept) = futf::classify(buf, i) else {
return false;
};
if !wtf8_meaningful(codept.meaning) {
return false;
}
Expand Down
14 changes: 4 additions & 10 deletions tendril/src/futf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@ unsafe fn unsafe_slice<'a>(buf: &'a [u8], start: usize, new_len: usize) -> &'a [
slice::from_raw_parts(buf.as_ptr().offset(start as isize), new_len)
}

macro_rules! otry {
($x:expr) => {
unwrap_or_return!($x, None)
};
}

/// Describes the UTF-8 codepoint containing the byte at index `idx` within
/// `buf`.
///
Expand All @@ -159,7 +153,7 @@ pub fn classify<'a>(buf: &'a [u8], idx: usize) -> Option<Codepoint<'a>> {

unsafe {
let x = *buf.get_unchecked(idx);
match otry!(Byte::classify(x)) {
match Byte::classify(x)? {
Byte::Ascii => Some(Codepoint {
bytes: unsafe_slice(buf, idx, 1),
rewind: 0,
Expand All @@ -172,7 +166,7 @@ pub fn classify<'a>(buf: &'a [u8], idx: usize) -> Option<Codepoint<'a>> {
if !all_cont(unsafe_slice(bytes, 1, n - 1)) {
return None;
}
let meaning = otry!(decode(bytes));
let meaning = decode(bytes)?;
Some(Codepoint {
bytes: bytes,
rewind: 0,
Expand Down Expand Up @@ -201,7 +195,7 @@ pub fn classify<'a>(buf: &'a [u8], idx: usize) -> Option<Codepoint<'a>> {

start -= 1;
checked += 1;
match otry!(Byte::classify(*buf.get_unchecked(start))) {
match Byte::classify(*buf.get_unchecked(start))? {
Byte::Cont => (),
Byte::Start(n) => {
let avail = buf.len() - start;
Expand All @@ -212,7 +206,7 @@ pub fn classify<'a>(buf: &'a [u8], idx: usize) -> Option<Codepoint<'a>> {
return None;
}
}
let meaning = otry!(decode(bytes));
let meaning = decode(bytes)?;
return Some(Codepoint {
bytes: bytes,
rewind: idx - start,
Expand Down
2 changes: 0 additions & 2 deletions tendril/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ extern crate debug_unreachable;
pub extern crate encoding;
#[cfg(feature = "encoding_rs")]
pub extern crate encoding_rs;
#[macro_use]
extern crate mac;
extern crate utf8;

pub use fmt::Format;
Expand Down
2 changes: 1 addition & 1 deletion tendril/src/tendril.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ where
let (class, first_mismatch);
{
let mut chars = unsafe { F::char_indices(self.as_byte_slice()) };
let (_, first) = unwrap_or_return!(chars.next(), None);
let (_, first) = chars.next()?;
class = classify(first);
first_mismatch = chars.find(|&(_, ch)| &classify(ch) != &class);
}
Expand Down