Snap for 8564071 from bd8e405fbb6cfa58acb6dfcaaa72ca7e1f44b594 to mainline-tethering-release

Change-Id: Iee2c834c5c2de6f1e34dbd377b22b18c621f078a
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"
   }
 }
diff --git a/Android.bp b/Android.bp
index 0354de3..c6f4848 100644
--- a/Android.bp
+++ b/Android.bp
@@ -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 @@
     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",
-    crate_name: "unicode_xid",
-    srcs: ["src/lib.rs"],
-    test_suites: ["general-tests"],
-    auto_gen_config: true,
-    edition: "2015",
-    features: ["default"],
-}
-
-rust_test_host {
-    name: "unicode-xid_host_test_src_lib",
-    defaults: ["unicode-xid_defaults"],
-}
-
 rust_test {
-    name: "unicode-xid_device_test_src_lib",
-    defaults: ["unicode-xid_defaults"],
-}
-
-rust_defaults {
-    name: "unicode-xid_defaults_exhaustive_tests",
-    crate_name: "exhaustive_tests",
-    srcs: ["tests/exhaustive_tests.rs"],
+    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"],
     rustlibs: [
-        "libunicode_xid",
+        "libcriterion",
     ],
 }
 
-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"],
+    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",
+    ],
 }
diff --git a/Cargo.toml b/Cargo.toml
index 0c1e1a8..c80b0aa 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,8 +12,8 @@
 
 [package]
 name = "unicode-xid"
-version = "0.2.1"
-authors = ["erick.tryzelaar <[email protected]>", "kwantam <[email protected]>"]
+version = "0.2.2"
+authors = ["erick.tryzelaar <[email protected]>", "kwantam <[email protected]>", "Manish Goregaokar <[email protected]>"]
 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 @@
 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 <[email protected]>",
            "kwantam <[email protected]>",
+           "Manish Goregaokar <[email protected]>"
            ]
 
 homepage = "https://github.com/unicode-rs/unicode-xid"
@@ -26,3 +27,10 @@
 default = []
 no_std = []
 bench = []
+
+[dev-dependencies]
+criterion = "0.3"
+
+[[bench]]
+name = "xid"
+harness = false
diff --git a/METADATA b/METADATA
index b9409a2..f57ea40 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   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
   }
 }
diff --git a/README.md b/README.md
index 242ec56..5910b40 100644
--- a/README.md
+++ b/README.md
@@ -26,6 +26,15 @@
 
 # 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": "unicode-xid_device_test_tests_exhaustive_tests"
+      "name": "apkdmverity.test"
     },
     {
-      "name": "futures-util_device_test_src_lib"
+      "name": "authfs_device_test_src_lib"
     },
     {
-      "name": "libsqlite3-sys_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_test_src_lib"
+    },
+    {
+      "name": "unicode-xid_test_tests_exhaustive_tests"
+    },
+    {
+      "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
diff --git a/src/lib.rs b/src/lib.rs
index 927fc9a..012124f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -75,11 +75,19 @@
 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))
     }
 }