Skip to content

Commit

Permalink
Merge pull request #10 from ZackPierce/fix_bench_and_cleanup
Browse files Browse the repository at this point in the history
Fix CI build by updating feature associated with 'bench' feature
  • Loading branch information
Manishearth authored Jul 15, 2019
2 parents 488b6c4 + 87a1511 commit 6a681a7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions scripts/unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def escape_char(c):

def emit_bsearch_range_table(f):
f.write("""
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
fn bsearch_range_table(c: char, r: &[(char,char)]) -> bool {
use core::cmp::Ordering::{Equal, Less, Greater};
r.binary_search_by(|&(lo,hi)| {
Expand All @@ -135,7 +135,7 @@ def emit_bsearch_range_table(f):
}\n
""")

def emit_table(f, name, t_data, t_type = "&'static [(char, char)]", is_pub=True,
def emit_table(f, name, t_data, t_type = "&[(char, char)]", is_pub=True,
pfun=lambda x: "(%s,%s)" % (escape_char(x[0]), escape_char(x[1])), is_const=True):
pub_string = "const"
if not is_const:
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png")]

#![no_std]
#![cfg_attr(feature = "bench", feature(test, unicode))]
#![cfg_attr(feature = "bench", feature(test, rustc_private))]

#[cfg(test)]
#[macro_use]
Expand Down
4 changes: 2 additions & 2 deletions src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
}

pub mod derived_property {
pub const XID_Continue_table: &'static [(char, char)] = &[
pub const XID_Continue_table: &[(char, char)] = &[
('\u{30}', '\u{39}'), ('\u{41}', '\u{5a}'), ('\u{5f}', '\u{5f}'), ('\u{61}', '\u{7a}'),
('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'), ('\u{b7}', '\u{b7}'), ('\u{ba}', '\u{ba}'),
('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'),
Expand Down Expand Up @@ -241,7 +241,7 @@ pub mod derived_property {
super::bsearch_range_table(c, XID_Continue_table)
}

pub const XID_Start_table: &'static [(char, char)] = &[
pub const XID_Start_table: &[(char, char)] = &[
('\u{41}', '\u{5a}'), ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'),
('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'),
('\u{2c6}', '\u{2d1}'), ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}',
Expand Down
14 changes: 6 additions & 8 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ use test::Bencher;
#[cfg(feature = "bench")]
use std::prelude::v1::*;

use super::UnicodeXID;

#[cfg(feature = "bench")]
#[bench]
fn cargo_is_xid_start(b: &mut Bencher) {
let string = iter::repeat('a').take(4096).collect::<String>();

b.bytes = string.len() as u64;
b.iter(|| {
string.chars().all(UnicodeXID::is_xid_start)
string.chars().all(super::UnicodeXID::is_xid_start)
});
}

Expand All @@ -46,7 +44,7 @@ fn cargo_xid_continue(b: &mut Bencher) {

b.bytes = string.len() as u64;
b.iter(|| {
string.chars().all(UnicodeXID::is_xid_continue)
string.chars().all(super::UnicodeXID::is_xid_continue)
});
}

Expand All @@ -69,7 +67,7 @@ fn test_is_xid_start() {
];

for ch in &chars {
assert!(UnicodeXID::is_xid_start(*ch), "{}", ch);
assert!(super::UnicodeXID::is_xid_start(*ch), "{}", ch);
}
}

Expand All @@ -83,7 +81,7 @@ fn test_is_not_xid_start() {
];

for ch in &chars {
assert!(!UnicodeXID::is_xid_start(*ch), "{}", ch);
assert!(!super::UnicodeXID::is_xid_start(*ch), "{}", ch);
}
}

Expand All @@ -95,7 +93,7 @@ fn test_is_xid_continue() {
];

for ch in &chars {
assert!(UnicodeXID::is_xid_continue(*ch), "{}", ch);
assert!(super::UnicodeXID::is_xid_continue(*ch), "{}", ch);
}
}

Expand All @@ -108,6 +106,6 @@ fn test_is_not_xid_continue() {
];

for &ch in &chars {
assert!(!UnicodeXID::is_xid_continue(ch), "{}", ch);
assert!(!super::UnicodeXID::is_xid_continue(ch), "{}", ch);
}
}

0 comments on commit 6a681a7

Please sign in to comment.