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
6 changes: 5 additions & 1 deletion library/core/src/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,11 @@ impl char {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_control(self) -> bool {
unicode::Cc(self)
// According to
// https://www.unicode.org/policies/stability_policy.html#Property_Value,
// the set of codepoints in `Cc` will never change.
// So we can just hard-code the patterns to match against instead of using a table.
matches!(self, '\0'..='\x1f' | '\x7f'..='\u{9f}')
}

/// Returns `true` if this `char` has the `Grapheme_Extend` property.
Expand Down
1 change: 0 additions & 1 deletion library/core/src/unicode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub use unicode_data::conversions;

#[rustfmt::skip]
pub(crate) use unicode_data::alphabetic::lookup as Alphabetic;
pub(crate) use unicode_data::cc::lookup as Cc;
pub(crate) use unicode_data::grapheme_extend::lookup as Grapheme_Extend;
pub(crate) use unicode_data::lowercase::lookup as Lowercase;
pub(crate) use unicode_data::n::lookup as N;
Expand Down
25 changes: 0 additions & 25 deletions library/core/src/unicode/unicode_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,31 +358,6 @@ pub mod cased {
}
}

#[rustfmt::skip]
pub mod cc {
use super::ShortOffsetRunHeader;

static SHORT_OFFSET_RUNS: [ShortOffsetRunHeader; 1] = [
ShortOffsetRunHeader::new(0, 1114272),
];
static OFFSETS: [u8; 5] = [
0, 32, 95, 33, 0,
];
pub fn lookup(c: char) -> bool {
const {
assert!(SHORT_OFFSET_RUNS.last().unwrap().0 > char::MAX as u32);
let mut i = 0;
while i < SHORT_OFFSET_RUNS.len() {
assert!(SHORT_OFFSET_RUNS[i].start_index() < OFFSETS.len());
i += 1;
}
}
// SAFETY: We just ensured the last element of `SHORT_OFFSET_RUNS` is greater than `std::char::MAX`
// and the start indices of all elements in `SHORT_OFFSET_RUNS` are smaller than `OFFSETS.len()`.
unsafe { super::skip_search(c, &SHORT_OFFSET_RUNS, &OFFSETS) }
}
}

#[rustfmt::skip]
pub mod grapheme_extend {
use super::ShortOffsetRunHeader;
Expand Down
1 change: 0 additions & 1 deletion src/tools/unicode-table-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ static PROPERTIES: &[&str] = &[
"Case_Ignorable",
"Grapheme_Extend",
"White_Space",
"Cc",
"N",
];

Expand Down
Loading