Skip to content

Commit 3347248

Browse files
committed
Add clone_from to Map; Map::append now uses IndexMap::extend
1 parent ca41bdd commit 3347248

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/map.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,8 @@ impl Map<String, Value> {
197197
#[inline]
198198
pub fn append(&mut self, other: &mut Self) {
199199
#[cfg(feature = "preserve_order")]
200-
for (k, v) in mem::replace(&mut other.map, MapImpl::default()) {
201-
self.map.insert(k, v);
202-
}
200+
self.map
201+
.extend(mem::replace(&mut other.map, MapImpl::default()));
203202
#[cfg(not(feature = "preserve_order"))]
204203
self.map.append(&mut other.map);
205204
}
@@ -304,6 +303,11 @@ impl Clone for Map<String, Value> {
304303
map: self.map.clone(),
305304
}
306305
}
306+
307+
#[inline]
308+
fn clone_from(&mut self, source: &Self) {
309+
self.map.clone_from(&source.map)
310+
}
307311
}
308312

309313
impl PartialEq for Map<String, Value> {

0 commit comments

Comments
 (0)