diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-10 07:09:13 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-10 07:09:13 +0000 |
commit | 95533e923f84301d28b14441d39bcd2beefca360 (patch) | |
tree | 2f638b0af631bc4d9825f4ea5d5afa19e188b68a | |
parent | 66aa931da96a6b29447023d1348cd911f0835444 (diff) | |
parent | bd8e405fbb6cfa58acb6dfcaaa72ca7e1f44b594 (diff) | |
download | unicode-xid-android13-mainline-adbd-release.tar.gz |
Snap for 8564071 from bd8e405fbb6cfa58acb6dfcaaa72ca7e1f44b594 to mainline-adbd-releaseaml_adb_331610000aml_adb_331314020aml_adb_331113120aml_adb_331011050aml_adb_331011040android13-mainline-adbd-release
Change-Id: I07c8786c49cf5d1f0d33a327a48917dfee214112
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 47 | ||||
-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 | 233 | ||||
-rw-r--r-- | benches/xid.rs | 60 | ||||
-rw-r--r-- | cargo2android.json | 5 | ||||
-rw-r--r-- | src/lib.rs | 12 |
10 files changed, 358 insertions, 40 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. +// This file is generated by cargo2android.py --config cargo2android.json. +// Do not modify this file as changes will be overridden on upgrade. package { default_applicable_licenses: ["external_rust_crates_unicode-xid_license"], @@ -41,50 +42,48 @@ rust_library { name: "libunicode_xid", host_supported: true, crate_name: "unicode_xid", + cargo_env_compat: true, + cargo_pkg_version: "0.2.2", srcs: ["src/lib.rs"], edition: "2015", features: ["default"], } -rust_defaults { - name: "unicode-xid_defaults", +rust_test { + name: "unicode-xid_test_src_lib", + host_supported: true, crate_name: "unicode_xid", + cargo_env_compat: true, + cargo_pkg_version: "0.2.2", srcs: ["src/lib.rs"], test_suites: ["general-tests"], auto_gen_config: true, + test_options: { + unit_test: true, + }, edition: "2015", features: ["default"], -} - -rust_test_host { - name: "unicode-xid_host_test_src_lib", - defaults: ["unicode-xid_defaults"], + rustlibs: [ + "libcriterion", + ], } rust_test { - name: "unicode-xid_device_test_src_lib", - defaults: ["unicode-xid_defaults"], -} - -rust_defaults { - name: "unicode-xid_defaults_exhaustive_tests", + name: "unicode-xid_test_tests_exhaustive_tests", + host_supported: true, crate_name: "exhaustive_tests", + cargo_env_compat: true, + cargo_pkg_version: "0.2.2", srcs: ["tests/exhaustive_tests.rs"], test_suites: ["general-tests"], auto_gen_config: true, + test_options: { + unit_test: true, + }, edition: "2015", features: ["default"], rustlibs: [ + "libcriterion", "libunicode_xid", ], } - -rust_test_host { - name: "unicode-xid_host_test_tests_exhaustive_tests", - defaults: ["unicode-xid_defaults_exhaustive_tests"], -} - -rust_test { - name: "unicode-xid_device_test_tests_exhaustive_tests", - defaults: ["unicode-xid_defaults_exhaustive_tests"], -} @@ -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..c74c9b1 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,17 +1,240 @@ -// Generated by cargo2android.py for tests in Android.bp +// Generated by update_crate_tests.py for tests that depend on this crate. { + "imports": [ + { + "path": "external/rust/crates/anyhow" + }, + { + "path": "external/rust/crates/arbitrary" + }, + { + "path": "external/rust/crates/argh" + }, + { + "path": "external/rust/crates/base64" + }, + { + "path": "external/rust/crates/bitflags" + }, + { + "path": "external/rust/crates/bytes" + }, + { + "path": "external/rust/crates/either" + }, + { + "path": "external/rust/crates/futures-util" + }, + { + "path": "external/rust/crates/jni" + }, + { + "path": "external/rust/crates/libm" + }, + { + "path": "external/rust/crates/libsqlite3-sys" + }, + { + "path": "external/rust/crates/oid-registry" + }, + { + "path": "external/rust/crates/rand_chacha" + }, + { + "path": "external/rust/crates/serde" + }, + { + "path": "external/rust/crates/serde-xml-rs" + }, + { + "path": "external/rust/crates/serde_cbor" + }, + { + "path": "external/rust/crates/slab" + }, + { + "path": "external/rust/crates/tinytemplate" + }, + { + "path": "external/rust/crates/tinyvec" + }, + { + "path": "external/rust/crates/tokio" + }, + { + "path": "external/rust/crates/tokio-test" + }, + { + "path": "external/rust/crates/unicode-bidi" + }, + { + "path": "external/rust/crates/url" + } + ], "presubmit": [ { - "name": "unicode-xid_device_test_src_lib" + "name": "ZipFuseTest" + }, + { + "name": "apkdmverity.test" + }, + { + "name": "authfs_device_test_src_lib" + }, + { + "name": "diced_open_dice_cbor_test" + }, + { + "name": "diced_sample_inputs_test" + }, + { + "name": "diced_test" + }, + { + "name": "diced_utils_test" + }, + { + "name": "diced_vendor_test" + }, + { + "name": "doh_unit_test" + }, + { + "name": "keystore2_crypto_test_rust" + }, + { + "name": "keystore2_km_compat_test" + }, + { + "name": "keystore2_selinux_concurrency_test" + }, + { + "name": "keystore2_selinux_test" + }, + { + "name": "keystore2_test" + }, + { + "name": "keystore2_test_utils_test" + }, + { + "name": "keystore2_vintf_test" + }, + { + "name": "legacykeystore_test" + }, + { + "name": "libapkverify.integration_test" + }, + { + "name": "libapkverify.test" + }, + { + "name": "libcert_request_validator_tests" + }, + { + "name": "libidsig.test" + }, + { + "name": "librustutils_test" + }, + { + "name": "microdroid_manager_test" + }, + { + "name": "rustBinderTest" + }, + { + "name": "unicode-xid_test_src_lib" + }, + { + "name": "unicode-xid_test_tests_exhaustive_tests" + }, + { + "name": "virtualizationservice_device_test" + } + ], + "presubmit-rust": [ + { + "name": "ZipFuseTest" + }, + { + "name": "apkdmverity.test" + }, + { + "name": "authfs_device_test_src_lib" + }, + { + "name": "diced_open_dice_cbor_test" + }, + { + "name": "diced_sample_inputs_test" + }, + { + "name": "diced_test" + }, + { + "name": "diced_utils_test" + }, + { + "name": "diced_vendor_test" + }, + { + "name": "doh_unit_test" + }, + { + "name": "keystore2_crypto_test_rust" + }, + { + "name": "keystore2_km_compat_test" + }, + { + "name": "keystore2_selinux_concurrency_test" + }, + { + "name": "keystore2_selinux_test" + }, + { + "name": "keystore2_test" + }, + { + "name": "keystore2_test_utils_test" + }, + { + "name": "keystore2_vintf_test" + }, + { + "name": "legacykeystore_test" + }, + { + "name": "libapkverify.integration_test" + }, + { + "name": "libapkverify.test" + }, + { + "name": "libcert_request_validator_tests" + }, + { + "name": "libidsig.test" + }, + { + "name": "librustutils_test" + }, + { + "name": "microdroid_manager_test" + }, + { + "name": "rustBinderTest" }, { - "name": "unicode-xid_device_test_tests_exhaustive_tests" + "name": "unicode-xid_test_src_lib" }, { - "name": "futures-util_device_test_src_lib" + "name": "unicode-xid_test_tests_exhaustive_tests" }, { - "name": "libsqlite3-sys_device_test_src_lib" + "name": "virtualizationservice_device_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); diff --git a/cargo2android.json b/cargo2android.json new file mode 100644 index 0000000..d36fb44 --- /dev/null +++ b/cargo2android.json @@ -0,0 +1,5 @@ +{ + "device": true, + "run": true, + "tests": true +}
\ No newline at end of file @@ -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)) } } |