summaryrefslogtreecommitdiff
path: root/vendor/string_cache
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-02 18:36:06 -0600
committermo khan <mo@mokhan.ca>2025-07-02 18:36:06 -0600
commit8cdfa445d6629ffef4cb84967ff7017654045bc2 (patch)
tree22f0b0907c024c78d26a731e2e1f5219407d8102 /vendor/string_cache
parent4351c74c7c5f97156bc94d3a8549b9940ac80e3f (diff)
chore: add vendor directory
Diffstat (limited to 'vendor/string_cache')
-rw-r--r--vendor/string_cache/.cargo-checksum.json1
-rw-r--r--vendor/string_cache/Cargo.lock245
-rw-r--r--vendor/string_cache/Cargo.toml66
-rw-r--r--vendor/string_cache/LICENSE-APACHE201
-rw-r--r--vendor/string_cache/LICENSE-MIT25
-rw-r--r--vendor/string_cache/README.md78
-rw-r--r--vendor/string_cache/examples/simple.rs26
-rw-r--r--vendor/string_cache/src/atom.rs415
-rw-r--r--vendor/string_cache/src/dynamic_set.rs112
-rw-r--r--vendor/string_cache/src/lib.rs139
-rw-r--r--vendor/string_cache/src/static_sets.rs64
-rw-r--r--vendor/string_cache/src/trivial_impls.rs119
-rw-r--r--vendor/string_cache/tests/small-stack.rs17
13 files changed, 1508 insertions, 0 deletions
diff --git a/vendor/string_cache/.cargo-checksum.json b/vendor/string_cache/.cargo-checksum.json
new file mode 100644
index 00000000..daeaf5ed
--- /dev/null
+++ b/vendor/string_cache/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"Cargo.lock":"a9ae67d7007fc899516ac9900a80b10508d5a09f638aa1d3923526bc42dc3654","Cargo.toml":"8aff6ac44ff9c301e774ef07c5e851d25ef9a3aa9d59095e7d16e997a173305e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"d13530e5e0d72b9106c735c276f88fd11aeaaccb404dda75a74d2cfafbf59268","examples/simple.rs":"227cbe14cdb0cb710a259707144b259684e9576615247628b8d57c895dd8c538","src/atom.rs":"730c2cbb12f62df28451a0f67b5edde5cc4721c59d032f8aef4b64afd4774858","src/dynamic_set.rs":"b18029c3f32b64bedd22eaa97c703ad9d36fd017e0449e1e173a729e8c94d337","src/lib.rs":"844ad2b53bde6f0d65650b9b034b91bdcece1ac285c0f2a97fea04382b6917e2","src/static_sets.rs":"0d91d476b5277cf3cbbcd0c9f18cc5286086fecf59654115efab5090862ec8e8","src/trivial_impls.rs":"ba12375f21c5f033a52bdf10dd6ab366702e1d68954aa012fc90cc7efc2a5ed3","tests/small-stack.rs":"f3c8dd5f38eba6e41aa44fe7a4af3a2a2e5bfc0a1fb938e76319d9780956177c"},"package":"bf776ba3fa74f83bf4b63c3dcbbf82173db2632ed8452cb2d891d33f459de70f"} \ No newline at end of file
diff --git a/vendor/string_cache/Cargo.lock b/vendor/string_cache/Cargo.lock
new file mode 100644
index 00000000..cf2d9b44
--- /dev/null
+++ b/vendor/string_cache/Cargo.lock
@@ -0,0 +1,245 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "autocfg"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
+
+[[package]]
+name = "bitflags"
+version = "2.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
+
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
+name = "libc"
+version = "0.2.171"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
+
+[[package]]
+name = "lock_api"
+version = "0.4.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
+dependencies = [
+ "autocfg",
+ "scopeguard",
+]
+
+[[package]]
+name = "malloc_size_of"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5d719de8b8f230028cf8192ae4c1b25267cd6b8a99d2747d345a70b8c81aa13"
+
+[[package]]
+name = "new_debug_unreachable"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
+
+[[package]]
+name = "parking_lot"
+version = "0.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
+dependencies = [
+ "lock_api",
+ "parking_lot_core",
+]
+
+[[package]]
+name = "parking_lot_core"
+version = "0.9.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "redox_syscall",
+ "smallvec",
+ "windows-targets",
+]
+
+[[package]]
+name = "phf_shared"
+version = "0.11.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
+dependencies = [
+ "siphasher",
+]
+
+[[package]]
+name = "precomputed-hash"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.94"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.40"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "redox_syscall"
+version = "0.5.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1"
+dependencies = [
+ "bitflags",
+]
+
+[[package]]
+name = "scopeguard"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
+[[package]]
+name = "serde"
+version = "1.0.219"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.219"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "siphasher"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
+
+[[package]]
+name = "smallvec"
+version = "1.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
+
+[[package]]
+name = "string_cache"
+version = "0.8.9"
+dependencies = [
+ "malloc_size_of",
+ "new_debug_unreachable",
+ "parking_lot",
+ "phf_shared",
+ "precomputed-hash",
+ "serde",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
+
+[[package]]
+name = "windows-targets"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
diff --git a/vendor/string_cache/Cargo.toml b/vendor/string_cache/Cargo.toml
new file mode 100644
index 00000000..9829e3ea
--- /dev/null
+++ b/vendor/string_cache/Cargo.toml
@@ -0,0 +1,66 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies.
+#
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
+
+[package]
+edition = "2018"
+rust-version = "1.70.0"
+name = "string_cache"
+version = "0.8.9"
+authors = ["The Servo Project Developers"]
+build = false
+autolib = false
+autobins = false
+autoexamples = false
+autotests = false
+autobenches = false
+description = "A string interning library for Rust, developed as part of the Servo project."
+documentation = "https://docs.rs/string_cache"
+readme = "README.md"
+license = "MIT OR Apache-2.0"
+repository = "https://github.com/servo/string-cache"
+
+[lib]
+name = "string_cache"
+path = "src/lib.rs"
+
+[[example]]
+name = "simple"
+path = "examples/simple.rs"
+
+[[test]]
+name = "small-stack"
+path = "tests/small-stack.rs"
+harness = false
+
+[dependencies.malloc_size_of]
+version = "0.1"
+optional = true
+default-features = false
+
+[dependencies.new_debug_unreachable]
+version = "1.0.2"
+
+[dependencies.parking_lot]
+version = "0.12"
+
+[dependencies.phf_shared]
+version = "0.11"
+
+[dependencies.precomputed-hash]
+version = "0.1"
+
+[dependencies.serde]
+version = "1"
+optional = true
+
+[features]
+default = ["serde_support"]
+serde_support = ["serde"]
diff --git a/vendor/string_cache/LICENSE-APACHE b/vendor/string_cache/LICENSE-APACHE
new file mode 100644
index 00000000..16fe87b0
--- /dev/null
+++ b/vendor/string_cache/LICENSE-APACHE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/vendor/string_cache/LICENSE-MIT b/vendor/string_cache/LICENSE-MIT
new file mode 100644
index 00000000..807526f5
--- /dev/null
+++ b/vendor/string_cache/LICENSE-MIT
@@ -0,0 +1,25 @@
+Copyright (c) 2012-2013 Mozilla Foundation
+
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without
+limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software
+is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/vendor/string_cache/README.md b/vendor/string_cache/README.md
new file mode 100644
index 00000000..fdf4c0a3
--- /dev/null
+++ b/vendor/string_cache/README.md
@@ -0,0 +1,78 @@
+# string-cache
+
+[![Build Status](https://github.com/servo/string-cache/actions/workflows/ci.yml/badge.svg)](https://github.com/servo/string-cache/actions)
+
+[Documentation](https://docs.rs/string_cache/)
+
+A string interning library for Rust, developed as part of the [Servo](https://github.com/servo/servo) project.
+
+## Simple usage
+
+In `Cargo.toml`:
+
+```toml
+[dependencies]
+string_cache = "0.8"
+```
+
+In `lib.rs`:
+
+```rust
+extern crate string_cache;
+use string_cache::DefaultAtom as Atom;
+```
+
+## With static atoms
+
+In `Cargo.toml`:
+
+```toml
+[package]
+build = "build.rs"
+
+[dependencies]
+string_cache = "0.8"
+
+[build-dependencies]
+string_cache_codegen = "0.5"
+```
+
+In `build.rs`:
+
+```rust
+extern crate string_cache_codegen;
+
+use std::env;
+use std::path::Path;
+
+fn main() {
+ string_cache_codegen::AtomType::new("foo::FooAtom", "foo_atom!")
+ .atoms(&["foo", "bar"])
+ .write_to_file(&Path::new(&env::var("OUT_DIR").unwrap()).join("foo_atom.rs"))
+ .unwrap()
+}
+```
+
+In `lib.rs`:
+
+```rust
+extern crate string_cache;
+
+mod foo {
+ include!(concat!(env!("OUT_DIR"), "/foo_atom.rs"));
+}
+```
+
+The generated code will define a `FooAtom` type and a `foo_atom!` macro.
+The macro can be used in expression or patterns, with strings listed in `build.rs`.
+For example:
+
+```rust
+fn compute_something(input: &foo::FooAtom) -> u32 {
+ match *input {
+ foo_atom!("foo") => 1,
+ foo_atom!("bar") => 2,
+ _ => 3,
+ }
+}
+```
diff --git a/vendor/string_cache/examples/simple.rs b/vendor/string_cache/examples/simple.rs
new file mode 100644
index 00000000..f063b06b
--- /dev/null
+++ b/vendor/string_cache/examples/simple.rs
@@ -0,0 +1,26 @@
+
+
+use string_cache::DefaultAtom;
+
+fn main() {
+ let mut interned_stuff = Vec::new();
+ let text = "here is a sentence of text that will be tokenised and interned and some repeated \
+ tokens is of text and";
+ for word in text.split_whitespace() {
+ let seen_before = interned_stuff
+ .iter()
+ // We can use impl PartialEq<T> where T is anything string-like to compare to
+ // interned strings to either other interned strings, or actual strings Comparing two
+ // interned strings is very fast (normally a single cpu operation).
+ .filter(|interned_word| interned_word == &word)
+ .count();
+ if seen_before > 0 {
+ println!(r#"Seen the word "{}" {} times"#, word, seen_before);
+ } else {
+ println!(r#"Not seen the word "{}" before"#, word);
+ }
+ // We use the impl From<(Cow<'a, str>, or &'a str, or String) for Atom<Static> to intern a
+ // new string
+ interned_stuff.push(DefaultAtom::from(word));
+ }
+}
diff --git a/vendor/string_cache/src/atom.rs b/vendor/string_cache/src/atom.rs
new file mode 100644
index 00000000..5a8aa7f0
--- /dev/null
+++ b/vendor/string_cache/src/atom.rs
@@ -0,0 +1,415 @@
+// Copyright 2014 The Servo Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use crate::dynamic_set::{dynamic_set, Entry};
+use crate::static_sets::StaticAtomSet;
+use debug_unreachable::debug_unreachable;
+
+use std::borrow::Cow;
+use std::cmp::Ordering::{self, Equal};
+use std::fmt;
+use std::hash::{Hash, Hasher};
+use std::marker::PhantomData;
+use std::mem;
+use std::num::NonZeroU64;
+use std::ops;
+use std::slice;
+use std::str;
+use std::sync::atomic::Ordering::SeqCst;
+
+const DYNAMIC_TAG: u8 = 0b_00;
+const INLINE_TAG: u8 = 0b_01; // len in upper nybble
+const STATIC_TAG: u8 = 0b_10;
+const TAG_MASK: u64 = 0b_11;
+const LEN_OFFSET: u64 = 4;
+const LEN_MASK: u64 = 0xF0;
+
+const MAX_INLINE_LEN: usize = 7;
+const STATIC_SHIFT_BITS: usize = 32;
+
+/// Represents a string that has been interned.
+///
+/// While the type definition for `Atom` indicates that it generic on a particular
+/// implementation of an atom set, you don't need to worry about this. Atoms can be static
+/// and come from a `StaticAtomSet` generated by the `string_cache_codegen` crate, or they
+/// can be dynamic and created by you on an `EmptyStaticAtomSet`.
+///
+/// `Atom` implements `Clone` but not `Copy`, since internally atoms are reference-counted;
+/// this means that you may need to `.clone()` an atom to keep copies to it in different
+/// places, or when passing it to a function that takes an `Atom` rather than an `&Atom`.
+///
+/// ## Creating an atom at runtime
+///
+/// If you use `string_cache_codegen` to generate a precomputed list of atoms, your code
+/// may then do something like read data from somewhere and extract tokens that need to be
+/// compared to the atoms. In this case, you can use `Atom::from(&str)` or
+/// `Atom::from(String)`. These create a reference-counted atom which will be
+/// automatically freed when all references to it are dropped.
+///
+/// This means that your application can safely have a loop which tokenizes data, creates
+/// atoms from the tokens, and compares the atoms to a predefined set of keywords, without
+/// running the risk of arbitrary memory consumption from creating large numbers of atoms —
+/// as long as your application does not store clones of the atoms it creates along the
+/// way.
+///
+/// For example, the following is safe and will not consume arbitrary amounts of memory:
+///
+/// ```ignore
+/// let untrusted_data = "large amounts of text ...";
+///
+/// for token in untrusted_data.split_whitespace() {
+/// let atom = Atom::from(token); // interns the string
+///
+/// if atom == Atom::from("keyword") {
+/// // handle that keyword
+/// } else if atom == Atom::from("another_keyword") {
+/// // handle that keyword
+/// } else {
+/// println!("unknown keyword");
+/// }
+/// } // atom is dropped here, so it is not kept around in memory
+/// ```
+#[derive(PartialEq, Eq)]
+// NOTE: Deriving PartialEq requires that a given string must always be interned the same way.
+pub struct Atom<Static> {
+ unsafe_data: NonZeroU64,
+ phantom: PhantomData<Static>,
+}
+
+// This isn't really correct as the Atoms can technically take up space. But I guess it's ok
+// as it is possible to measure the size of the atom set separately/
+#[cfg(feature = "malloc_size_of")]
+impl<Static: StaticAtomSet> malloc_size_of::MallocSizeOf for Atom<Static> {
+ fn size_of(&self, _ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
+ 0
+ }
+}
+
+// FIXME: bound removed from the struct definition before of this error for pack_static:
+// "error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable"
+// https://github.com/rust-lang/rust/issues/57563
+impl<Static> Atom<Static> {
+ /// For the atom!() macros
+ #[inline(always)]
+ #[doc(hidden)]
+ pub const fn pack_static(n: u32) -> Self {
+ Self {
+ unsafe_data: unsafe {
+ // STATIC_TAG ensures this is non-zero
+ NonZeroU64::new_unchecked((STATIC_TAG as u64) | ((n as u64) << STATIC_SHIFT_BITS))
+ },
+ phantom: PhantomData,
+ }
+ }
+
+ /// For the atom!() macros
+ #[inline(always)]
+ #[doc(hidden)]
+ pub const fn pack_inline(mut n: u64, len: u8) -> Self {
+ if cfg!(target_endian = "big") {
+ // Reverse order of top 7 bytes.
+ // Bottom 8 bits of `n` are zero, and we need that to remain so.
+ // String data is stored in top 7 bytes, tag and length in bottom byte.
+ n = n.to_le() << 8;
+ }
+
+ let data: u64 = (INLINE_TAG as u64) | ((len as u64) << LEN_OFFSET) | n;
+ Self {
+ // INLINE_TAG ensures this is never zero
+ unsafe_data: unsafe { NonZeroU64::new_unchecked(data) },
+ phantom: PhantomData,
+ }
+ }
+
+ fn tag(&self) -> u8 {
+ (self.unsafe_data.get() & TAG_MASK) as u8
+ }
+}
+
+impl<Static: StaticAtomSet> Atom<Static> {
+ /// Return the internal representation. For testing.
+ #[doc(hidden)]
+ pub fn unsafe_data(&self) -> u64 {
+ self.unsafe_data.get()
+ }
+
+ /// Return true if this is a static Atom. For testing.
+ #[doc(hidden)]
+ pub fn is_static(&self) -> bool {
+ self.tag() == STATIC_TAG
+ }
+
+ /// Return true if this is a dynamic Atom. For testing.
+ #[doc(hidden)]
+ pub fn is_dynamic(&self) -> bool {
+ self.tag() == DYNAMIC_TAG
+ }
+
+ /// Return true if this is an inline Atom. For testing.
+ #[doc(hidden)]
+ pub fn is_inline(&self) -> bool {
+ self.tag() == INLINE_TAG
+ }
+
+ fn static_index(&self) -> u64 {
+ self.unsafe_data.get() >> STATIC_SHIFT_BITS
+ }
+
+ /// Get the hash of the string as it is stored in the set.
+ pub fn get_hash(&self) -> u32 {
+ match self.tag() {
+ DYNAMIC_TAG => {
+ let entry = self.unsafe_data.get() as *const Entry;
+ unsafe { (*entry).hash }
+ }
+ STATIC_TAG => Static::get().hashes[self.static_index() as usize],
+ INLINE_TAG => {
+ let data = self.unsafe_data.get();
+ // This may or may not be great...
+ ((data >> 32) ^ data) as u32
+ }
+ _ => unsafe { debug_unreachable!() },
+ }
+ }
+
+ pub fn try_static(string_to_add: &str) -> Option<Self> {
+ Self::try_static_internal(string_to_add).ok()
+ }
+
+ fn try_static_internal(string_to_add: &str) -> Result<Self, phf_shared::Hashes> {
+ let static_set = Static::get();
+ let hash = phf_shared::hash(&*string_to_add, &static_set.key);
+ let index = phf_shared::get_index(&hash, static_set.disps, static_set.atoms.len());
+
+ if static_set.atoms[index as usize] == string_to_add {
+ Ok(Self::pack_static(index))
+ } else {
+ Err(hash)
+ }
+ }
+}
+
+impl<Static: StaticAtomSet> Default for Atom<Static> {
+ #[inline]
+ fn default() -> Self {
+ Atom::pack_static(Static::empty_string_index())
+ }
+}
+
+impl<Static: StaticAtomSet> Hash for Atom<Static> {
+ #[inline]
+ fn hash<H>(&self, state: &mut H)
+ where
+ H: Hasher,
+ {
+ state.write_u32(self.get_hash())
+ }
+}
+
+impl<'a, Static: StaticAtomSet> From<Cow<'a, str>> for Atom<Static> {
+ fn from(string_to_add: Cow<'a, str>) -> Self {
+ let len = string_to_add.len();
+ if len == 0 {
+ Self::pack_static(Static::empty_string_index())
+ } else if len <= MAX_INLINE_LEN {
+ let mut data: u64 = (INLINE_TAG as u64) | ((len as u64) << LEN_OFFSET);
+ {
+ let dest = inline_atom_slice_mut(&mut data);
+ dest[..len].copy_from_slice(string_to_add.as_bytes());
+ }
+ Atom {
+ // INLINE_TAG ensures this is never zero
+ unsafe_data: unsafe { NonZeroU64::new_unchecked(data) },
+ phantom: PhantomData,
+ }
+ } else {
+ Self::try_static_internal(&*string_to_add).unwrap_or_else(|hash| {
+ let ptr: std::ptr::NonNull<Entry> = dynamic_set().insert(string_to_add, hash.g);
+ let data = ptr.as_ptr() as u64;
+ debug_assert!(0 == data & TAG_MASK);
+ Atom {
+ // The address of a ptr::NonNull is non-zero
+ unsafe_data: unsafe { NonZeroU64::new_unchecked(data) },
+ phantom: PhantomData,
+ }
+ })
+ }
+ }
+}
+
+impl<Static: StaticAtomSet> Clone for Atom<Static> {
+ #[inline(always)]
+ fn clone(&self) -> Self {
+ if self.tag() == DYNAMIC_TAG {
+ let entry = self.unsafe_data.get() as *const Entry;
+ unsafe { &*entry }.ref_count.fetch_add(1, SeqCst);
+ }
+ Atom { ..*self }
+ }
+}
+
+impl<Static> Drop for Atom<Static> {
+ #[inline]
+ fn drop(&mut self) {
+ if self.tag() == DYNAMIC_TAG {
+ let entry = self.unsafe_data.get() as *const Entry;
+ if unsafe { &*entry }.ref_count.fetch_sub(1, SeqCst) == 1 {
+ drop_slow(self)
+ }
+ }
+
+ // Out of line to guide inlining.
+ fn drop_slow<Static>(this: &mut Atom<Static>) {
+ dynamic_set().remove(this.unsafe_data.get() as *mut Entry);
+ }
+ }
+}
+
+impl<Static: StaticAtomSet> ops::Deref for Atom<Static> {
+ type Target = str;
+
+ #[inline]
+ fn deref(&self) -> &str {
+ unsafe {
+ match self.tag() {
+ DYNAMIC_TAG => {
+ let entry = self.unsafe_data.get() as *const Entry;
+ &(*entry).string
+ }
+ INLINE_TAG => {
+ let len = (self.unsafe_data() & LEN_MASK) >> LEN_OFFSET;
+ debug_assert!(len as usize <= MAX_INLINE_LEN);
+ let src = inline_atom_slice(&self.unsafe_data);
+ str::from_utf8_unchecked(src.get_unchecked(..(len as usize)))
+ }
+ STATIC_TAG => Static::get().atoms[self.static_index() as usize],
+ _ => debug_unreachable!(),
+ }
+ }
+ }
+}
+
+impl<Static: StaticAtomSet> fmt::Debug for Atom<Static> {
+ #[inline]
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ let ty_str = unsafe {
+ match self.tag() {
+ DYNAMIC_TAG => "dynamic",
+ INLINE_TAG => "inline",
+ STATIC_TAG => "static",
+ _ => debug_unreachable!(),
+ }
+ };
+
+ write!(f, "Atom('{}' type={})", &*self, ty_str)
+ }
+}
+
+impl<Static: StaticAtomSet> PartialOrd for Atom<Static> {
+ #[inline]
+ fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
+ if self.unsafe_data == other.unsafe_data {
+ return Some(Equal);
+ }
+ self.as_ref().partial_cmp(other.as_ref())
+ }
+}
+
+impl<Static: StaticAtomSet> Ord for Atom<Static> {
+ #[inline]
+ fn cmp(&self, other: &Self) -> Ordering {
+ if self.unsafe_data == other.unsafe_data {
+ return Equal;
+ }
+ self.as_ref().cmp(other.as_ref())
+ }
+}
+
+// AsciiExt requires mutating methods, so we just implement the non-mutating ones.
+// We don't need to implement is_ascii because there's no performance improvement
+// over the one from &str.
+impl<Static: StaticAtomSet> Atom<Static> {
+ fn from_mutated_str<F: FnOnce(&mut str)>(s: &str, f: F) -> Self {
+ let mut buffer = mem::MaybeUninit::<[u8; 64]>::uninit();
+ let buffer = unsafe { &mut *buffer.as_mut_ptr() };
+
+ if let Some(buffer_prefix) = buffer.get_mut(..s.len()) {
+ buffer_prefix.copy_from_slice(s.as_bytes());
+ let as_str = unsafe { ::std::str::from_utf8_unchecked_mut(buffer_prefix) };
+ f(as_str);
+ Atom::from(&*as_str)
+ } else {
+ let mut string = s.to_owned();
+ f(&mut string);
+ Atom::from(string)
+ }
+ }
+
+ /// Like [`to_ascii_uppercase`].
+ ///
+ /// [`to_ascii_uppercase`]: https://doc.rust-lang.org/std/ascii/trait.AsciiExt.html#tymethod.to_ascii_uppercase
+ pub fn to_ascii_uppercase(&self) -> Self {
+ for (i, b) in self.bytes().enumerate() {
+ if let b'a'..=b'z' = b {
+ return Atom::from_mutated_str(self, |s| s[i..].make_ascii_uppercase());
+ }
+ }
+ self.clone()
+ }
+
+ /// Like [`to_ascii_lowercase`].
+ ///
+ /// [`to_ascii_lowercase`]: https://doc.rust-lang.org/std/ascii/trait.AsciiExt.html#tymethod.to_ascii_lowercase
+ pub fn to_ascii_lowercase(&self) -> Self {
+ for (i, b) in self.bytes().enumerate() {
+ if let b'A'..=b'Z' = b {
+ return Atom::from_mutated_str(self, |s| s[i..].make_ascii_lowercase());
+ }
+ }
+ self.clone()
+ }
+
+ /// Like [`eq_ignore_ascii_case`].
+ ///
+ /// [`eq_ignore_ascii_case`]: https://doc.rust-lang.org/std/ascii/trait.AsciiExt.html#tymethod.eq_ignore_ascii_case
+ pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool {
+ (self == other) || self.eq_str_ignore_ascii_case(&**other)
+ }
+
+ /// Like [`eq_ignore_ascii_case`], but takes an unhashed string as `other`.
+ ///
+ /// [`eq_ignore_ascii_case`]: https://doc.rust-lang.org/std/ascii/trait.AsciiExt.html#tymethod.eq_ignore_ascii_case
+ pub fn eq_str_ignore_ascii_case(&self, other: &str) -> bool {
+ (&**self).eq_ignore_ascii_case(other)
+ }
+}
+
+#[inline(always)]
+fn inline_atom_slice(x: &NonZeroU64) -> &[u8] {
+ let x: *const NonZeroU64 = x;
+ let mut data = x as *const u8;
+ // All except the lowest byte, which is first in little-endian, last in big-endian.
+ if cfg!(target_endian = "little") {
+ data = unsafe { data.offset(1) };
+ }
+ let len = 7;
+ unsafe { slice::from_raw_parts(data, len) }
+}
+
+#[inline(always)]
+fn inline_atom_slice_mut(x: &mut u64) -> &mut [u8] {
+ let x: *mut u64 = x;
+ let mut data = x as *mut u8;
+ // All except the lowest byte, which is first in little-endian, last in big-endian.
+ if cfg!(target_endian = "little") {
+ data = unsafe { data.offset(1) };
+ }
+ let len = 7;
+ unsafe { slice::from_raw_parts_mut(data, len) }
+}
diff --git a/vendor/string_cache/src/dynamic_set.rs b/vendor/string_cache/src/dynamic_set.rs
new file mode 100644
index 00000000..4442b4da
--- /dev/null
+++ b/vendor/string_cache/src/dynamic_set.rs
@@ -0,0 +1,112 @@
+// Copyright 2014 The Servo Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use parking_lot::Mutex;
+use std::borrow::Cow;
+use std::mem;
+use std::ptr::NonNull;
+use std::sync::atomic::AtomicIsize;
+use std::sync::atomic::Ordering::SeqCst;
+use std::sync::OnceLock;
+
+const NB_BUCKETS: usize = 1 << 12; // 4096
+const BUCKET_MASK: u32 = (1 << 12) - 1;
+
+pub(crate) struct Set {
+ buckets: Box<[Mutex<Option<Box<Entry>>>]>,
+}
+
+pub(crate) struct Entry {
+ pub(crate) string: Box<str>,
+ pub(crate) hash: u32,
+ pub(crate) ref_count: AtomicIsize,
+ next_in_bucket: Option<Box<Entry>>,
+}
+
+// Addresses are a multiples of this,
+// and therefore have have TAG_MASK bits unset, available for tagging.
+pub(crate) const ENTRY_ALIGNMENT: usize = 4;
+
+#[test]
+fn entry_alignment_is_sufficient() {
+ assert!(mem::align_of::<Entry>() >= ENTRY_ALIGNMENT);
+}
+
+pub(crate) fn dynamic_set() -> &'static Set {
+ // NOTE: Using const initialization for buckets breaks the small-stack test.
+ // ```
+ // // buckets: [Mutex<Option<Box<Entry>>>; NB_BUCKETS],
+ // const MUTEX: Mutex<Option<Box<Entry>>> = Mutex::new(None);
+ // let buckets = Box::new([MUTEX; NB_BUCKETS]);
+ // ```
+ static DYNAMIC_SET: OnceLock<Set> = OnceLock::new();
+
+ DYNAMIC_SET.get_or_init(|| {
+ let buckets = (0..NB_BUCKETS).map(|_| Mutex::new(None)).collect();
+ Set { buckets }
+ })
+}
+
+impl Set {
+ pub(crate) fn insert(&self, string: Cow<str>, hash: u32) -> NonNull<Entry> {
+ let bucket_index = (hash & BUCKET_MASK) as usize;
+ let mut linked_list = self.buckets[bucket_index].lock();
+
+ {
+ let mut ptr: Option<&mut Box<Entry>> = linked_list.as_mut();
+
+ while let Some(entry) = ptr.take() {
+ if entry.hash == hash && *entry.string == *string {
+ if entry.ref_count.fetch_add(1, SeqCst) > 0 {
+ return NonNull::from(&mut **entry);
+ }
+ // Uh-oh. The pointer's reference count was zero, which means someone may try
+ // to free it. (Naive attempts to defend against this, for example having the
+ // destructor check to see whether the reference count is indeed zero, don't
+ // work due to ABA.) Thus we need to temporarily add a duplicate string to the
+ // list.
+ entry.ref_count.fetch_sub(1, SeqCst);
+ break;
+ }
+ ptr = entry.next_in_bucket.as_mut();
+ }
+ }
+ debug_assert!(mem::align_of::<Entry>() >= ENTRY_ALIGNMENT);
+ let string = string.into_owned();
+ let mut entry = Box::new(Entry {
+ next_in_bucket: linked_list.take(),
+ hash,
+ ref_count: AtomicIsize::new(1),
+ string: string.into_boxed_str(),
+ });
+ let ptr = NonNull::from(&mut *entry);
+ *linked_list = Some(entry);
+ ptr
+ }
+
+ pub(crate) fn remove(&self, ptr: *mut Entry) {
+ let value: &Entry = unsafe { &*ptr };
+ let bucket_index = (value.hash & BUCKET_MASK) as usize;
+
+ let mut linked_list = self.buckets[bucket_index].lock();
+ debug_assert!(value.ref_count.load(SeqCst) == 0);
+ let mut current: &mut Option<Box<Entry>> = &mut linked_list;
+
+ while let Some(entry_ptr) = current.as_mut() {
+ let entry_ptr: *mut Entry = &mut **entry_ptr;
+ if entry_ptr == ptr {
+ mem::drop(mem::replace(current, unsafe {
+ (*entry_ptr).next_in_bucket.take()
+ }));
+ break;
+ }
+ current = unsafe { &mut (*entry_ptr).next_in_bucket };
+ }
+ }
+}
diff --git a/vendor/string_cache/src/lib.rs b/vendor/string_cache/src/lib.rs
new file mode 100644
index 00000000..441cb4ef
--- /dev/null
+++ b/vendor/string_cache/src/lib.rs
@@ -0,0 +1,139 @@
+// Copyright 2014 The Servo Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//!
+//! A library for interning things that are `AsRef<str>`.
+//!
+//! Some strings may be interned at compile time using the `string-cache-codegen` crate, or the
+//! `EmptyStaticAtomSet` may be used that has no compile-time interned strings. An `Atom` is an
+//! interned string for a given set (either `EmptyStaticAtomSet` or a generated `StaticAtomSet`).
+//!
+//! Generated `Atom`s will have assocated macros to intern static strings at compile-time.
+//!
+//! # Examples
+//!
+//! Here are two examples, one with compile-time `Atom`s, and one without.
+//!
+//! ## With compile-time atoms
+//!
+//! In `Cargo.toml`:
+//! ```toml
+//! [dependencies]
+//! string_cache = "0.8"
+//!
+//! [dev-dependencies]
+//! string_cache_codegen = "0.5"
+//! ```
+//!
+//! In `build.rs`:
+//!
+//! ```ignore
+//! extern crate string_cache_codegen;
+//!
+//! use std::env;
+//! use std::path::Path;
+//!
+//! fn main() {
+//! string_cache_codegen::AtomType::new("foo::FooAtom", "foo_atom!")
+//! .atoms(&["foo", "bar"])
+//! .write_to_file(&Path::new(&env::var("OUT_DIR").unwrap()).join("foo_atom.rs"))
+//! .unwrap()
+//! }
+//! ```
+//!
+//! In `lib.rs`:
+//!
+//! ```ignore
+//! extern crate string_cache;
+//!
+//! mod foo {
+//! include!(concat!(env!("OUT_DIR"), "/foo_atom.rs"));
+//! }
+//!
+//! fn use_the_atom(t: &str) {
+//! match *t {
+//! foo_atom!("foo") => println!("Found foo!"),
+//! foo_atom!("bar") => println!("Found bar!"),
+//! // foo_atom!("baz") => println!("Found baz!"), - would be a compile time error
+//! _ => {
+//! println!("String not interned");
+//! // We can intern strings at runtime as well
+//! foo::FooAtom::from(t)
+//! }
+//! }
+//! }
+//! ```
+//!
+//! ## No compile-time atoms
+//!
+//! ```
+//! # extern crate string_cache;
+//! use string_cache::DefaultAtom;
+//!
+//! # fn main() {
+//! let mut interned_stuff = Vec::new();
+//! let text = "here is a sentence of text that will be tokenised and
+//! interned and some repeated tokens is of text and";
+//! for word in text.split_whitespace() {
+//! let seen_before = interned_stuff.iter()
+//! // We can use impl PartialEq<T> where T is anything string-like
+//! // to compare to interned strings to either other interned strings,
+//! // or actual strings Comparing two interned strings is very fast
+//! // (normally a single cpu operation).
+//! .filter(|interned_word| interned_word == &word)
+//! .count();
+//! if seen_before > 0 {
+//! println!(r#"Seen the word "{}" {} times"#, word, seen_before);
+//! } else {
+//! println!(r#"Not seen the word "{}" before"#, word);
+//! }
+//! // We use the impl From<(Cow<'a, str>, or &'a str, or String)> for
+//! // Atom<Static> to intern a new string.
+//! interned_stuff.push(DefaultAtom::from(word));
+//! }
+//! # }
+//! ```
+//!
+
+#![cfg_attr(test, deny(warnings))]
+
+// Types, such as Atom, that impl Hash must follow the hash invariant: if two objects match
+// with PartialEq, they must also have the same Hash. Clippy warns on types that derive one while
+// manually impl-ing the other, because it seems easy for the two to drift apart, causing the
+// invariant to be violated.
+//
+// But Atom is a newtype over NonZeroU64, and probably always will be, since cheap comparisons and
+// copying are this library's purpose. So we know what the PartialEq comparison is going to do.
+//
+// The `get_hash` function, seen in `atom.rs`, consults that number, plus the global string interner
+// tables. The only way for the resulting hash for two Atoms with the same inner 64-bit number to
+// differ would be if the table entry changed between invocations, and that would be really bad.
+#![allow(clippy::derive_hash_xor_eq)]
+
+mod atom;
+mod dynamic_set;
+mod static_sets;
+mod trivial_impls;
+
+pub use atom::Atom;
+pub use static_sets::{EmptyStaticAtomSet, PhfStrSet, StaticAtomSet};
+
+/// Use this if you don’t care about static atoms.
+pub type DefaultAtom = Atom<EmptyStaticAtomSet>;
+
+// Some minor tests of internal layout here.
+// See ../integration-tests for much more.
+
+/// Guard against accidental changes to the sizes of things.
+#[test]
+fn assert_sizes() {
+ use std::mem::size_of;
+ assert_eq!(size_of::<DefaultAtom>(), 8);
+ assert_eq!(size_of::<Option<DefaultAtom>>(), size_of::<DefaultAtom>(),);
+}
diff --git a/vendor/string_cache/src/static_sets.rs b/vendor/string_cache/src/static_sets.rs
new file mode 100644
index 00000000..f7f1799f
--- /dev/null
+++ b/vendor/string_cache/src/static_sets.rs
@@ -0,0 +1,64 @@
+// Copyright 2014 The Servo Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+/// A static `PhfStrSet`
+///
+/// This trait is implemented by static sets of interned strings generated using
+/// `string_cache_codegen`, and `EmptyStaticAtomSet` for when strings will be added dynamically.
+///
+/// It is used by the methods of [`Atom`] to check if a string is present in the static set.
+///
+/// [`Atom`]: struct.Atom.html
+pub trait StaticAtomSet: Ord {
+ /// Get the location of the static string set in the binary.
+ fn get() -> &'static PhfStrSet;
+ /// Get the index of the empty string, which is in every set and is used for `Atom::default`.
+ fn empty_string_index() -> u32;
+}
+
+/// A string set created using a [perfect hash function], specifically
+/// [Hash, Displace and Compress].
+///
+/// See the CHD document for the meaning of the struct fields.
+///
+/// [perfect hash function]: https://en.wikipedia.org/wiki/Perfect_hash_function
+/// [Hash, Displace and Compress]: http://cmph.sourceforge.net/papers/esa09.pdf
+pub struct PhfStrSet {
+ #[doc(hidden)]
+ pub key: u64,
+ #[doc(hidden)]
+ pub disps: &'static [(u32, u32)],
+ #[doc(hidden)]
+ pub atoms: &'static [&'static str],
+ #[doc(hidden)]
+ pub hashes: &'static [u32],
+}
+
+/// An empty static atom set for when only dynamic strings will be added
+#[derive(PartialEq, Eq, PartialOrd, Ord)]
+pub struct EmptyStaticAtomSet;
+
+impl StaticAtomSet for EmptyStaticAtomSet {
+ fn get() -> &'static PhfStrSet {
+ // The name is a lie: this set is not empty (it contains the empty string)
+ // but that’s only to avoid divisions by zero in rust-phf.
+ static SET: PhfStrSet = PhfStrSet {
+ key: 0,
+ disps: &[(0, 0)],
+ atoms: &[""],
+ // "" SipHash'd, and xored with u64_hash_to_u32.
+ hashes: &[0x3ddddef3],
+ };
+ &SET
+ }
+
+ fn empty_string_index() -> u32 {
+ 0
+ }
+}
diff --git a/vendor/string_cache/src/trivial_impls.rs b/vendor/string_cache/src/trivial_impls.rs
new file mode 100644
index 00000000..960dde0d
--- /dev/null
+++ b/vendor/string_cache/src/trivial_impls.rs
@@ -0,0 +1,119 @@
+// Copyright 2014 The Servo Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use crate::{Atom, StaticAtomSet};
+#[cfg(feature = "serde_support")]
+use serde::{Deserialize, Deserializer, Serialize, Serializer};
+use std::borrow::Cow;
+use std::fmt;
+
+impl<Static: StaticAtomSet> ::precomputed_hash::PrecomputedHash for Atom<Static> {
+ fn precomputed_hash(&self) -> u32 {
+ self.get_hash()
+ }
+}
+
+impl<'a, Static: StaticAtomSet> From<&'a Atom<Static>> for Atom<Static> {
+ fn from(atom: &'a Self) -> Self {
+ atom.clone()
+ }
+}
+
+impl<Static: StaticAtomSet> PartialEq<str> for Atom<Static> {
+ fn eq(&self, other: &str) -> bool {
+ &self[..] == other
+ }
+}
+
+impl<Static: StaticAtomSet> PartialEq<Atom<Static>> for str {
+ fn eq(&self, other: &Atom<Static>) -> bool {
+ self == &other[..]
+ }
+}
+
+impl<Static: StaticAtomSet> PartialEq<String> for Atom<Static> {
+ fn eq(&self, other: &String) -> bool {
+ self[..] == other[..]
+ }
+}
+
+impl<'a, Static: StaticAtomSet> From<&'a str> for Atom<Static> {
+ #[inline]
+ fn from(string_to_add: &str) -> Self {
+ Atom::from(Cow::Borrowed(string_to_add))
+ }
+}
+
+impl<Static: StaticAtomSet> From<String> for Atom<Static> {
+ #[inline]
+ fn from(string_to_add: String) -> Self {
+ Atom::from(Cow::Owned(string_to_add))
+ }
+}
+
+impl<Static: StaticAtomSet> fmt::Display for Atom<Static> {
+ #[inline]
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ <str as fmt::Display>::fmt(self, f)
+ }
+}
+
+impl<Static: StaticAtomSet> AsRef<str> for Atom<Static> {
+ fn as_ref(&self) -> &str {
+ self
+ }
+}
+
+#[cfg(feature = "serde_support")]
+impl<Static: StaticAtomSet> Serialize for Atom<Static> {
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ let string: &str = self.as_ref();
+ string.serialize(serializer)
+ }
+}
+
+#[cfg(feature = "serde_support")]
+impl<'a, Static: StaticAtomSet> Deserialize<'a> for Atom<Static> {
+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+ where
+ D: Deserializer<'a>,
+ {
+ use serde::de;
+ use std::marker::PhantomData;
+
+ struct AtomVisitor<Static: StaticAtomSet>(PhantomData<Static>);
+
+ impl<'de, Static: StaticAtomSet> de::Visitor<'de> for AtomVisitor<Static> {
+ type Value = Atom<Static>;
+
+ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ write!(formatter, "an Atom")
+ }
+
+ fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
+ where
+ E: de::Error,
+ {
+ Ok(Atom::from(v))
+ }
+
+ fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
+ where
+ E: de::Error,
+ {
+ Ok(Atom::from(v))
+ }
+ }
+
+ deserializer.deserialize_str(AtomVisitor(PhantomData))
+ }
+}
diff --git a/vendor/string_cache/tests/small-stack.rs b/vendor/string_cache/tests/small-stack.rs
new file mode 100644
index 00000000..bb607af6
--- /dev/null
+++ b/vendor/string_cache/tests/small-stack.rs
@@ -0,0 +1,17 @@
+// Regression test for https://github.com/servo/html5ever/issues/393
+//
+// Create a dynamic atom − causing initialization of the global hash map −
+// in a thread that has a small stack.
+//
+// This is a separate test program rather than a `#[test] fn` among others
+// to make sure that nothing else has already initialized the map in this process.
+fn main() {
+ std::thread::Builder::new()
+ .stack_size(50_000)
+ .spawn(|| {
+ let _atom = string_cache::DefaultAtom::from("12345678");
+ })
+ .unwrap()
+ .join()
+ .unwrap()
+}