Snap for 11421525 from f4a1151ee3613c367a52e8c4ba02ce90c2cd0678 to simpleperf-release

Change-Id: Icb3a1f398e0d221e5b8d28c600541b84f3cb6abe
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 4866a89..e81232e 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,6 +1,6 @@
 {
   "git": {
-    "sha1": "151a9cea914bb8017470caeb467a208fd1ad99b3"
+    "sha1": "b709dcf8f0884f2e041aa6a6cb4cf54200aa5491"
   },
   "path_in_vcs": ""
 }
\ No newline at end of file
diff --git a/Android.bp b/Android.bp
index 432e304..1890764 100644
--- a/Android.bp
+++ b/Android.bp
@@ -23,7 +23,7 @@
     host_supported: true,
     crate_name: "slab",
     cargo_env_compat: true,
-    cargo_pkg_version: "0.4.8",
+    cargo_pkg_version: "0.4.9",
     srcs: ["src/lib.rs"],
     edition: "2018",
     features: [
@@ -46,7 +46,7 @@
     host_supported: true,
     crate_name: "slab",
     cargo_env_compat: true,
-    cargo_pkg_version: "0.4.8",
+    cargo_pkg_version: "0.4.9",
     srcs: ["tests/slab.rs"],
     test_suites: ["general-tests"],
     auto_gen_config: true,
diff --git a/CHANGELOG.md b/CHANGELOG.md
index db54582..f46a797 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,8 @@
-# 0.4.8 (January 20, 2022)
+# 0.4.9 (August 22, 2023)
+
+* Avoid reallocations in `Slab::clone_from` (#137)
+
+# 0.4.8 (January 20, 2023)
 
 * Fixed documentation about overflow (#124)
 * Document panic in `get2_mut` (#131)
diff --git a/Cargo.toml b/Cargo.toml
index 8823fb8..461bb8f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
 edition = "2018"
 rust-version = "1.31"
 name = "slab"
-version = "0.4.8"
+version = "0.4.9"
 authors = ["Carl Lerche <me@carllerche.com>"]
 exclude = ["/.*"]
 description = "Pre-allocated storage for a uniform data type"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index ae94bb4..1891355 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -6,7 +6,7 @@
 #   - README.md
 # - Update CHANGELOG.md
 # - Create git tag
-version = "0.4.8"
+version = "0.4.9"
 authors = ["Carl Lerche <me@carllerche.com>"]
 edition = "2018"
 rust-version = "1.31"
diff --git a/METADATA b/METADATA
index 447f06a..2f44dfc 100644
--- a/METADATA
+++ b/METADATA
@@ -1,23 +1,20 @@
 # This project was upgraded with external_updater.
-# Usage: tools/external_updater/updater.sh update rust/crates/slab
-# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+# Usage: tools/external_updater/updater.sh update external/rust/crates/slab
+# For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md
 
 name: "slab"
 description: "Pre-allocated storage for a uniform data type"
 third_party {
-  url {
-    type: HOMEPAGE
-    value: "https://crates.io/crates/slab"
-  }
-  url {
-    type: ARCHIVE
-    value: "https://static.crates.io/crates/slab/slab-0.4.8.crate"
-  }
-  version: "0.4.8"
   license_type: NOTICE
   last_upgrade_date {
-    year: 2023
-    month: 3
-    day: 6
+    year: 2024
+    month: 2
+    day: 5
+  }
+  homepage: "https://crates.io/crates/slab"
+  identifier {
+    type: "Archive"
+    value: "https://static.crates.io/crates/slab/slab-0.4.9.crate"
+    version: "0.4.9"
   }
 }
diff --git a/src/lib.rs b/src/lib.rs
index e23ead9..7fc6f1a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -129,7 +129,6 @@
 /// See the [module documentation] for more details.
 ///
 /// [module documentation]: index.html
-#[derive(Clone)]
 pub struct Slab<T> {
     // Chunk of memory
     entries: Vec<Entry<T>>,
@@ -142,6 +141,25 @@
     next: usize,
 }
 
+impl<T> Clone for Slab<T>
+where
+    T: Clone,
+{
+    fn clone(&self) -> Self {
+        Self {
+            entries: self.entries.clone(),
+            len: self.len,
+            next: self.next,
+        }
+    }
+
+    fn clone_from(&mut self, source: &Self) {
+        self.entries.clone_from(&source.entries);
+        self.len = source.len;
+        self.next = source.next;
+    }
+}
+
 impl<T> Default for Slab<T> {
     fn default() -> Self {
         Slab::new()
diff --git a/tests/slab.rs b/tests/slab.rs
index f446350..e18b40e 100644
--- a/tests/slab.rs
+++ b/tests/slab.rs
@@ -712,3 +712,24 @@
 fn const_new() {
     static _SLAB: Slab<()> = Slab::new();
 }
+
+#[test]
+fn clone_from() {
+    let mut slab1 = Slab::new();
+    let mut slab2 = Slab::new();
+    for i in 0..5 {
+        slab1.insert(i);
+        slab2.insert(2 * i);
+        slab2.insert(2 * i + 1);
+    }
+    slab1.remove(1);
+    slab1.remove(3);
+    slab2.clone_from(&slab1);
+
+    let mut iter2 = slab2.iter();
+    assert_eq!(iter2.next(), Some((0, &0)));
+    assert_eq!(iter2.next(), Some((2, &2)));
+    assert_eq!(iter2.next(), Some((4, &4)));
+    assert_eq!(iter2.next(), None);
+    assert!(slab2.capacity() >= 10);
+}