This repository was archived by the owner on Jul 10, 2023. It is now read-only.
File tree 2 files changed +14
-6
lines changed
2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " heapsize"
3
- version = " 0.3.1 "
3
+ version = " 0.3.2 "
4
4
authors = [ " The Servo Project Developers" ]
5
5
description = " Infrastructure for measuring the total runtime size of an object on the heap"
6
6
license = " MPL-2.0"
Original file line number Diff line number Diff line change 6
6
7
7
use std:: borrow:: Cow ;
8
8
use std:: cell:: { Cell , RefCell } ;
9
- use std:: collections:: { BTreeMap , HashMap , LinkedList } ;
9
+ use std:: collections:: { BTreeMap , HashMap , LinkedList , VecDeque } ;
10
10
#[ cfg( feature = "unstable" ) ]
11
11
use std:: hash:: BuildHasher ;
12
12
use std:: hash:: Hash ;
@@ -160,10 +160,18 @@ impl<T: HeapSizeOf + Copy> HeapSizeOf for Cell<T> {
160
160
161
161
impl < T : HeapSizeOf > HeapSizeOf for Vec < T > {
162
162
fn heap_size_of_children ( & self ) -> usize {
163
- unsafe {
164
- heap_size_of ( self . as_ptr ( ) as * const c_void )
165
- + self . iter ( ) . fold ( 0 , |n, elem| n + elem. heap_size_of_children ( ) )
166
- }
163
+ self . iter ( ) . fold (
164
+ unsafe { heap_size_of ( self . as_ptr ( ) as * const c_void ) } ,
165
+ |n, elem| n + elem. heap_size_of_children ( ) )
166
+ }
167
+ }
168
+
169
+ impl < T : HeapSizeOf > HeapSizeOf for VecDeque < T > {
170
+ fn heap_size_of_children ( & self ) -> usize {
171
+ self . iter ( ) . fold (
172
+ // FIXME: get the buffer pointer for heap_size_of(), capacity() is a lower bound:
173
+ self . capacity ( ) * size_of :: < T > ( ) ,
174
+ |n, elem| n + elem. heap_size_of_children ( ) )
167
175
}
168
176
}
169
177
You can’t perform that action at this time.
0 commit comments