Skip to content

Commit 83d2452

Browse files
committed
doc: refine use of the word 'unsafe'
This removes extraneous commentary that uses the word 'unsafe'. This makes it easier to grep for usages of meaningful 'unsafe' in the code.
1 parent f757094 commit 83d2452

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/backtrack.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ impl<'a, 'm, 'r, 's, I: Input> Bounded<'a, 'm, 'r, 's, I> {
115115
// Then we reset all existing allocated space to 0.
116116
// Finally, we request more space if we need it.
117117
//
118-
// This is all a little circuitous, but doing this unsafely
119-
// doesn't seem to have a measurable impact on performance.
118+
// This is all a little circuitous, but doing this using unchecked
119+
// operations doesn't seem to have a measurable impact on performance.
120120
// (Probably because backtracking is limited to such small
121121
// inputs/regexes in the first place.)
122122
let visited_len =

src/dfa.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ impl<'a> Fsm<'a> {
848848
/// next_si transitions to the next state, where the transition input
849849
/// corresponds to text[i].
850850
///
851-
/// This elides bounds checks, and is therefore unsafe.
851+
/// This elides bounds checks, and is therefore not safe.
852852
#[cfg_attr(feature = "perf-inline", inline(always))]
853853
unsafe fn next_si(&self, si: StatePtr, text: &[u8], i: usize) -> StatePtr {
854854
// What is the argument for safety here?
@@ -1688,7 +1688,7 @@ impl Transitions {
16881688
self.num_byte_classes * mem::size_of::<StatePtr>()
16891689
}
16901690

1691-
/// Like `next`, but uses unchecked access and is therefore unsafe.
1691+
/// Like `next`, but uses unchecked access and is therefore not safe.
16921692
unsafe fn next_unchecked(&self, si: StatePtr, cls: usize) -> StatePtr {
16931693
debug_assert!((si as usize) < self.table.len());
16941694
debug_assert!(cls < self.num_byte_classes);

src/expand.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ fn find_cap_ref(replacement: &[u8]) -> Option<CaptureRef> {
144144
}
145145
// We just verified that the range 0..cap_end is valid ASCII, so it must
146146
// therefore be valid UTF-8. If we really cared, we could avoid this UTF-8
147-
// check with either unsafe or by parsing the number straight from &[u8].
147+
// check via an unchecked conversion or by parsing the number straight from
148+
// &[u8].
148149
let cap =
149150
str::from_utf8(&rep[i..cap_end]).expect("valid UTF-8 capture name");
150151
Some(CaptureRef {

0 commit comments

Comments
 (0)