Skip to content

Commit f9ef8cd

Browse files
committed
Refactored code into Searcher traits with naive implementations
Made the family of Split iterators use the Pattern API Renamed the Matcher traits into Searcher
1 parent 13ea906 commit f9ef8cd

File tree

7 files changed

+476
-390
lines changed

7 files changed

+476
-390
lines changed

src/compiletest/compiletest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#![feature(env)]
2424
#![feature(core)]
2525

26-
#![deny(warnings)]
26+
// #![deny(warnings)]
2727

2828
extern crate test;
2929
extern crate getopts;

src/libcollections/str.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
706706
/// ```
707707
#[unstable(feature = "collections",
708708
reason = "might have its iterator type changed")]
709-
fn match_indices<'a>(&'a self, pat: &'a str) -> MatchIndices<'a> {
709+
fn match_indices<'a, 'b>(&'a self, pat: &'b str) -> MatchIndices<'a, &'b str> {
710710
core_str::StrExt::match_indices(&self[..], pat)
711711
}
712712

@@ -723,7 +723,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
723723
/// ```
724724
#[unstable(feature = "collections",
725725
reason = "might get removed in the future in favor of a more generic split()")]
726-
fn split_str<'a>(&'a self, pat: &'a str) -> SplitStr<'a> {
726+
fn split_str<'a, 'b>(&'a self, pat: &'b str) -> SplitStr<'a, &'b str> {
727727
core_str::StrExt::split_str(&self[..], pat)
728728
}
729729

src/libcore/char.rs

+15-12
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ use option::Option;
2222
use slice::SliceExt;
2323

2424
// UTF-8 ranges and tags for encoding characters
25-
static TAG_CONT: u8 = 0b1000_0000u8;
26-
static TAG_TWO_B: u8 = 0b1100_0000u8;
27-
static TAG_THREE_B: u8 = 0b1110_0000u8;
28-
static TAG_FOUR_B: u8 = 0b1111_0000u8;
29-
static MAX_ONE_B: u32 = 0x80u32;
30-
static MAX_TWO_B: u32 = 0x800u32;
31-
static MAX_THREE_B: u32 = 0x10000u32;
25+
const TAG_CONT: u8 = 0b1000_0000u8;
26+
const TAG_TWO_B: u8 = 0b1100_0000u8;
27+
const TAG_THREE_B: u8 = 0b1110_0000u8;
28+
const TAG_FOUR_B: u8 = 0b1111_0000u8;
29+
const MAX_ONE_B: u32 = 0x80u32;
30+
const MAX_TWO_B: u32 = 0x800u32;
31+
const MAX_THREE_B: u32 = 0x10000u32;
3232

3333
/*
3434
Lu Uppercase_Letter an uppercase letter
@@ -398,11 +398,14 @@ impl CharExt for char {
398398
#[stable(feature = "rust1", since = "1.0.0")]
399399
fn len_utf8(self) -> usize {
400400
let code = self as u32;
401-
match () {
402-
_ if code < MAX_ONE_B => 1,
403-
_ if code < MAX_TWO_B => 2,
404-
_ if code < MAX_THREE_B => 3,
405-
_ => 4,
401+
if code < MAX_ONE_B {
402+
1
403+
} else if code < MAX_TWO_B {
404+
2
405+
} else if code < MAX_THREE_B {
406+
3
407+
} else {
408+
4
406409
}
407410
}
408411

src/libcore/slice.rs

+4
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,8 @@ macro_rules! iterator {
657657
fn next(&mut self) -> Option<$elem> {
658658
// could be implemented with slices, but this avoids bounds checks
659659
unsafe {
660+
::intrinsics::assume(!self.ptr.is_null());
661+
::intrinsics::assume(!self.end.is_null());
660662
if self.ptr == self.end {
661663
None
662664
} else {
@@ -693,6 +695,8 @@ macro_rules! iterator {
693695
fn next_back(&mut self) -> Option<$elem> {
694696
// could be implemented with slices, but this avoids bounds checks
695697
unsafe {
698+
::intrinsics::assume(!self.ptr.is_null());
699+
::intrinsics::assume(!self.end.is_null());
696700
if self.end == self.ptr {
697701
None
698702
} else {

0 commit comments

Comments
 (0)