mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Avoid writing into the empty array header.
Differential Revision: https://phabricator.services.mozilla.com/D55291
This commit is contained in:
parent
f89c31120f
commit
80ac4d2ff2
1 changed files with 7 additions and 2 deletions
|
@ -89,9 +89,11 @@ impl<T> nsTArray<T> {
|
|||
pub unsafe fn set_len(&mut self, len: u32) {
|
||||
// this can leak
|
||||
debug_assert!(len >= self.len() as u32);
|
||||
if self.len() == len as usize {
|
||||
return;
|
||||
}
|
||||
self.ensure_capacity(len as usize);
|
||||
let header = self.header_mut();
|
||||
header.mLength = len;
|
||||
self.header_mut().mLength = len;
|
||||
}
|
||||
|
||||
/// Resizes an array containing only POD elements
|
||||
|
@ -103,6 +105,9 @@ impl<T> nsTArray<T> {
|
|||
where
|
||||
T: Copy,
|
||||
{
|
||||
if self.len() == len as usize {
|
||||
return;
|
||||
}
|
||||
self.ensure_capacity(len as usize);
|
||||
let header = self.header_mut();
|
||||
header.mLength = len;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue