diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-06-11 03:05:40 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-06-11 03:05:40 +0000 |
commit | 71667db6272421b58e9ebca499e57f179199c21c (patch) | |
tree | 0e31024fad4a350f2d398fbe032338fcc9840252 | |
parent | 37f711628638e343828d5c2cc8b265961d29d019 (diff) | |
parent | 65035869defc8b6a8ae40338d1a9a7731065d592 (diff) | |
download | unicode-xid-71667db6272421b58e9ebca499e57f179199c21c.tar.gz |
Snap for 7445904 from 65035869defc8b6a8ae40338d1a9a7731065d592 to tm-release
Change-Id: I8a0b84f8694595033a1a7bdd3bf462001fc45b18
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 69 | ||||
-rw-r--r-- | Cargo.toml | 10 | ||||
-rw-r--r-- | Cargo.toml.orig | 10 | ||||
-rw-r--r-- | METADATA | 10 | ||||
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | TEST_MAPPING | 222 | ||||
-rw-r--r-- | benches/xid.rs | 60 | ||||
-rw-r--r-- | src/lib.rs | 12 |
9 files changed, 390 insertions, 14 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 413d1c5..ad389b4 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "4c762c188a111d8dfa79c4770a06b20236db280f" + "sha1": "aa989880611f325b2eacc8c6da21e5826c11565c" } } @@ -1,4 +1,5 @@ // This file is generated by cargo2android.py --run --device --tests --dependencies. +// Do not modify this file as changes will be overridden on upgrade. package { default_applicable_licenses: ["external_rust_crates_unicode-xid_license"], @@ -54,11 +55,17 @@ rust_defaults { auto_gen_config: true, edition: "2015", features: ["default"], + rustlibs: [ + "libcriterion", + ], } rust_test_host { name: "unicode-xid_host_test_src_lib", defaults: ["unicode-xid_defaults"], + test_options: { + unit_test: true, + }, } rust_test { @@ -75,6 +82,7 @@ rust_defaults { edition: "2015", features: ["default"], rustlibs: [ + "libcriterion", "libunicode_xid", ], } @@ -82,9 +90,70 @@ rust_defaults { rust_test_host { name: "unicode-xid_host_test_tests_exhaustive_tests", defaults: ["unicode-xid_defaults_exhaustive_tests"], + test_options: { + unit_test: true, + }, } rust_test { name: "unicode-xid_device_test_tests_exhaustive_tests", defaults: ["unicode-xid_defaults_exhaustive_tests"], } + +// dependent_library ["feature_list"] +// atty-0.2.14 +// autocfg-1.0.1 +// bitflags-1.2.1 "default" +// bstr-0.2.16 "default,lazy_static,regex-automata,serde,serde1,serde1-nostd,std,unicode" +// byteorder-1.4.3 +// cast-0.2.6 "default,std" +// cfg-if-1.0.0 +// clap-2.33.3 +// criterion-0.3.4 "cargo_bench_support,default" +// criterion-plot-0.4.3 +// crossbeam-channel-0.5.1 "crossbeam-utils,default,std" +// crossbeam-deque-0.8.0 "crossbeam-epoch,crossbeam-utils,default,std" +// crossbeam-epoch-0.9.4 "alloc,lazy_static,std" +// crossbeam-utils-0.8.4 "default,lazy_static,std" +// csv-1.1.6 +// csv-core-0.1.10 "default" +// either-1.6.1 +// half-1.7.1 +// itertools-0.10.0 "default,use_alloc,use_std" +// itertools-0.9.0 "default,use_std" +// itoa-0.4.7 "default,std" +// lazy_static-1.4.0 +// libc-0.2.94 "default,std" +// memchr-2.4.0 "std" +// memoffset-0.6.3 "default" +// num-traits-0.2.14 "default,std" +// num_cpus-1.13.0 +// oorandom-11.1.3 +// pest-2.1.3 +// plotters-0.3.0 "area_series,line_series,plotters-svg,svg_backend" +// plotters-backend-0.3.0 +// plotters-svg-0.3.0 +// proc-macro2-1.0.26 "default,proc-macro" +// quote-1.0.9 "default,proc-macro" +// rayon-1.5.1 +// rayon-core-1.9.1 +// regex-1.5.4 "std" +// regex-automata-0.1.9 +// regex-syntax-0.6.25 +// rustc_version-0.3.3 +// ryu-1.0.5 +// same-file-1.0.6 +// scopeguard-1.1.0 +// semver-0.11.0 "default" +// semver-parser-0.10.2 +// serde-1.0.126 "default,std" +// serde_cbor-0.11.1 "default,std" +// serde_derive-1.0.126 "default" +// serde_json-1.0.64 "default,std" +// syn-1.0.72 "clone-impls,default,derive,full,parsing,printing,proc-macro,quote,visit" +// textwrap-0.11.0 +// tinytemplate-1.2.1 +// ucd-trie-0.1.3 "default,std" +// unicode-width-0.1.8 "default" +// unicode-xid-0.2.2 "default" +// walkdir-2.3.2 @@ -12,8 +12,8 @@ [package] name = "unicode-xid" -version = "0.2.1" -authors = ["erick.tryzelaar <erick.tryzelaar@gmail.com>", "kwantam <kwantam@gmail.com>"] +version = "0.2.2" +authors = ["erick.tryzelaar <erick.tryzelaar@gmail.com>", "kwantam <kwantam@gmail.com>", "Manish Goregaokar <manishsmail@gmail.com>"] exclude = ["/scripts/*", "/.travis.yml"] description = "Determine whether characters have the XID_Start\nor XID_Continue properties according to\nUnicode Standard Annex #31.\n" homepage = "https://github.com/unicode-rs/unicode-xid" @@ -23,6 +23,12 @@ keywords = ["text", "unicode", "xid"] license = "MIT OR Apache-2.0" repository = "https://github.com/unicode-rs/unicode-xid" +[[bench]] +name = "xid" +harness = false +[dev-dependencies.criterion] +version = "0.3" + [features] bench = [] default = [] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 0b20ce2..25a7b15 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,9 +1,10 @@ [package] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" authors = ["erick.tryzelaar <erick.tryzelaar@gmail.com>", "kwantam <kwantam@gmail.com>", + "Manish Goregaokar <manishsmail@gmail.com>" ] homepage = "https://github.com/unicode-rs/unicode-xid" @@ -26,3 +27,10 @@ travis-ci = { repository = "unicode-rs/unicode-xid" } default = [] no_std = [] bench = [] + +[dev-dependencies] +criterion = "0.3" + +[[bench]] +name = "xid" +harness = false @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/unicode-xid/unicode-xid-0.2.1.crate" + value: "https://static.crates.io/crates/unicode-xid/unicode-xid-0.2.2.crate" } - version: "0.2.1" + version: "0.2.2" license_type: NOTICE last_upgrade_date { - year: 2020 - month: 7 - day: 20 + year: 2021 + month: 5 + day: 19 } } @@ -26,6 +26,15 @@ on std, and instead uses equivalent functions from core. # changelog +## 0.2.2 + +- Add an ASCII fast-path + +## 0.2.1 + +- Update to Unicode 13.0.0 +- Speed up lookup + ## 0.2.0 - Update to Unicode 12.1.0. diff --git a/TEST_MAPPING b/TEST_MAPPING index 8965b1e..f46983d 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,17 +1,233 @@ -// Generated by cargo2android.py for tests in Android.bp +// Generated by update_crate_tests.py for tests that depend on this crate. { "presubmit": [ { - "name": "unicode-xid_device_test_src_lib" + "name": "ZipFuseTest" }, { - "name": "unicode-xid_device_test_tests_exhaustive_tests" + "name": "anyhow_device_test_src_lib" + }, + { + "name": "anyhow_device_test_tests_test_autotrait" + }, + { + "name": "anyhow_device_test_tests_test_boxed" + }, + { + "name": "anyhow_device_test_tests_test_chain" + }, + { + "name": "anyhow_device_test_tests_test_context" + }, + { + "name": "anyhow_device_test_tests_test_convert" + }, + { + "name": "anyhow_device_test_tests_test_downcast" + }, + { + "name": "anyhow_device_test_tests_test_ffi" + }, + { + "name": "anyhow_device_test_tests_test_fmt" + }, + { + "name": "anyhow_device_test_tests_test_macros" + }, + { + "name": "anyhow_device_test_tests_test_repr" + }, + { + "name": "anyhow_device_test_tests_test_source" + }, + { + "name": "authfs_device_test_src_lib" + }, + { + "name": "doh_unit_test" + }, + { + "name": "either_device_test_src_lib" }, { "name": "futures-util_device_test_src_lib" }, { + "name": "keystore2_crypto_test_rust" + }, + { + "name": "keystore2_selinux_concurrency_test" + }, + { + "name": "keystore2_selinux_test" + }, + { + "name": "keystore2_test" + }, + { + "name": "libm_device_test_src_lib" + }, + { "name": "libsqlite3-sys_device_test_src_lib" + }, + { + "name": "serde_cbor_device_test_src_lib" + }, + { + "name": "serde_cbor_device_test_tests_bennofs" + }, + { + "name": "serde_cbor_device_test_tests_canonical" + }, + { + "name": "serde_cbor_device_test_tests_de" + }, + { + "name": "serde_cbor_device_test_tests_enum" + }, + { + "name": "serde_cbor_device_test_tests_ser" + }, + { + "name": "serde_cbor_device_test_tests_std_types" + }, + { + "name": "serde_cbor_device_test_tests_tags" + }, + { + "name": "serde_cbor_device_test_tests_value" + }, + { + "name": "serde_test_device_test_src_lib" + }, + { + "name": "tokio-test_device_test_src_lib" + }, + { + "name": "tokio-test_device_test_tests_block_on" + }, + { + "name": "tokio-test_device_test_tests_io" + }, + { + "name": "tokio-test_device_test_tests_macros" + }, + { + "name": "tokio_device_test_tests_buffered" + }, + { + "name": "tokio_device_test_tests_io_async_read" + }, + { + "name": "tokio_device_test_tests_io_copy_bidirectional" + }, + { + "name": "tokio_device_test_tests_io_lines" + }, + { + "name": "tokio_device_test_tests_io_mem_stream" + }, + { + "name": "tokio_device_test_tests_io_read" + }, + { + "name": "tokio_device_test_tests_io_read_buf" + }, + { + "name": "tokio_device_test_tests_io_read_to_end" + }, + { + "name": "tokio_device_test_tests_io_take" + }, + { + "name": "tokio_device_test_tests_io_write" + }, + { + "name": "tokio_device_test_tests_io_write_all" + }, + { + "name": "tokio_device_test_tests_io_write_buf" + }, + { + "name": "tokio_device_test_tests_io_write_int" + }, + { + "name": "tokio_device_test_tests_macros_join" + }, + { + "name": "tokio_device_test_tests_no_rt" + }, + { + "name": "tokio_device_test_tests_rt_basic" + }, + { + "name": "tokio_device_test_tests_rt_threaded" + }, + { + "name": "tokio_device_test_tests_sync_barrier" + }, + { + "name": "tokio_device_test_tests_sync_broadcast" + }, + { + "name": "tokio_device_test_tests_sync_errors" + }, + { + "name": "tokio_device_test_tests_sync_mpsc" + }, + { + "name": "tokio_device_test_tests_sync_mutex_owned" + }, + { + "name": "tokio_device_test_tests_sync_rwlock" + }, + { + "name": "tokio_device_test_tests_sync_watch" + }, + { + "name": "tokio_device_test_tests_task_local" + }, + { + "name": "tokio_device_test_tests_task_local_set" + }, + { + "name": "tokio_device_test_tests_tcp_accept" + }, + { + "name": "tokio_device_test_tests_tcp_echo" + }, + { + "name": "tokio_device_test_tests_tcp_into_std" + }, + { + "name": "tokio_device_test_tests_tcp_shutdown" + }, + { + "name": "tokio_device_test_tests_time_rt" + }, + { + "name": "tokio_device_test_tests_uds_split" + }, + { + "name": "unicode-bidi_device_test_src_lib" + }, + { + "name": "unicode-xid_device_test_src_lib" + }, + { + "name": "unicode-xid_device_test_tests_exhaustive_tests" + }, + { + "name": "url_device_test_src_lib" + }, + { + "name": "url_device_test_tests_data" + }, + { + "name": "url_device_test_tests_unit" + }, + { + "name": "vpnprofilestore_test" } ] } diff --git a/benches/xid.rs b/benches/xid.rs new file mode 100644 index 0000000..a565c36 --- /dev/null +++ b/benches/xid.rs @@ -0,0 +1,60 @@ +extern crate criterion; +extern crate unicode_xid; + +use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; +use unicode_xid::UnicodeXID; + +fn bench_unicode_xid(c: &mut Criterion) { + let unicode_chars = chars(1..0x3000); + let ascii_chars = chars(1..0x80); + + let mut group = c.benchmark_group("UnicodeXID"); + group.throughput(Throughput::Bytes(unicode_chars.len() as u64)); + group.bench_with_input( + BenchmarkId::new("is_xid_start", "unicode"), + &unicode_chars, + |b, chars| b.iter(|| chars.iter().copied().map(UnicodeXID::is_xid_start).last()), + ); + group.throughput(Throughput::Bytes(ascii_chars.len() as u64)); + group.bench_with_input( + BenchmarkId::new("is_xid_start", "ascii"), + &ascii_chars, + |b, chars| b.iter(|| chars.iter().copied().map(UnicodeXID::is_xid_start).last()), + ); + group.throughput(Throughput::Bytes(unicode_chars.len() as u64)); + group.bench_with_input( + BenchmarkId::new("is_xid_continue", "unicode"), + &unicode_chars, + |b, chars| { + b.iter(|| { + chars + .iter() + .copied() + .map(UnicodeXID::is_xid_continue) + .last() + }) + }, + ); + group.throughput(Throughput::Bytes(ascii_chars.len() as u64)); + group.bench_with_input( + BenchmarkId::new("is_xid_continue", "ascii"), + &ascii_chars, + |b, chars| { + b.iter(|| { + chars + .iter() + .copied() + .map(UnicodeXID::is_xid_continue) + .last() + }) + }, + ); + group.finish(); +} + +fn chars(range: std::ops::Range<u32>) -> Vec<char> { + range.filter_map(|i| std::char::from_u32(i)).collect() +} + +criterion_group!(benches, bench_unicode_xid); +criterion_main!(benches); @@ -75,11 +75,19 @@ pub trait UnicodeXID { impl UnicodeXID for char { #[inline] fn is_xid_start(self) -> bool { - derived_property::XID_Start(self) + // Fast-path for ascii idents + ('a' <= self && self <= 'z') + || ('A' <= self && self <= 'Z') + || (self > '\x7f' && derived_property::XID_Start(self)) } #[inline] fn is_xid_continue(self) -> bool { - derived_property::XID_Continue(self) + // Fast-path for ascii idents + ('a' <= self && self <= 'z') + || ('A' <= self && self <= 'Z') + || ('0' <= self && self <= '9') + || self == '_' + || (self > '\x7f' && derived_property::XID_Continue(self)) } } |