Skip to content

Commit 63308bc

Browse files
committed
refactor(common): rm Input/find
1 parent 51507bc commit 63308bc

File tree

1 file changed

+11
-44
lines changed

1 file changed

+11
-44
lines changed

crates/swc_common/src/input.rs

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -177,34 +177,6 @@ impl<'a> Input<'a> for StringInput<'a> {
177177
ret
178178
}
179179

180-
fn find<F>(&mut self, mut pred: F) -> Option<BytePos>
181-
where
182-
F: FnMut(char) -> bool,
183-
{
184-
let last = {
185-
let mut last = 0;
186-
for c in self.iter.clone() {
187-
last += c.len_utf8();
188-
if pred(c) {
189-
break;
190-
}
191-
}
192-
last
193-
};
194-
195-
if last == 0 {
196-
return None;
197-
}
198-
199-
let s = self.iter.as_str();
200-
debug_assert!(last <= s.len());
201-
202-
self.last_pos = self.last_pos + BytePos(last as _);
203-
self.iter = unsafe { s.get_unchecked(last..) }.chars();
204-
205-
Some(self.last_pos)
206-
}
207-
208180
#[inline]
209181
unsafe fn reset_to(&mut self, to: BytePos) {
210182
let orig = self.orig;
@@ -284,11 +256,6 @@ pub trait Input<'a>: Clone {
284256
where
285257
F: FnMut(char) -> bool;
286258

287-
/// This method modifies [last_pos()] and [cur_pos()].
288-
fn find<F>(&mut self, f: F) -> Option<BytePos>
289-
where
290-
F: FnMut(char) -> bool;
291-
292259
/// # Safety
293260
///
294261
/// - `to` be in the valid range of input.
@@ -397,17 +364,17 @@ mod tests {
397364
});
398365
}
399366

400-
#[test]
401-
fn src_input_find_01() {
402-
with_test_sess("foo/d", |mut i| {
403-
assert_eq!(i.cur_pos(), BytePos(1));
404-
assert_eq!(i.last_pos, BytePos(1));
405-
406-
assert_eq!(i.find(|c| c == '/'), Some(BytePos(5)));
407-
assert_eq!(i.last_pos, BytePos(5));
408-
assert_eq!(i.cur(), Some('d'));
409-
});
410-
}
367+
// #[test]
368+
// fn src_input_find_01() {
369+
// with_test_sess("foo/d", |mut i| {
370+
// assert_eq!(i.cur_pos(), BytePos(1));
371+
// assert_eq!(i.last_pos, BytePos(1));
372+
373+
// assert_eq!(i.find(|c| c == '/'), Some(BytePos(5)));
374+
// assert_eq!(i.last_pos, BytePos(5));
375+
// assert_eq!(i.cur(), Some('d'));
376+
// });
377+
// }
411378

412379
// #[test]
413380
// fn src_input_smoke_02() {

0 commit comments

Comments
 (0)