##// END OF EJS Templates
rust-parsers: use in-place mutation instead of allocating a new `Vec`...
Raphaël Gomès -
r46223:1efbc787 default
parent child Browse files
Show More
@@ -107,12 +107,11 b' pub fn pack_dirstate('
107 107 let expected_size = expected_size + PARENT_SIZE * 2;
108 108
109 109 let mut packed = Vec::with_capacity(expected_size);
110 let mut new_state_map = vec![];
111 110
112 111 packed.extend(&parents.p1);
113 112 packed.extend(&parents.p2);
114 113
115 for (filename, entry) in state_map.iter() {
114 for (filename, entry) in state_map.iter_mut() {
116 115 let new_filename = filename.to_owned();
117 116 let mut new_mtime: i32 = entry.mtime;
118 117 if entry.state == EntryState::Normal && entry.mtime == now {
@@ -126,13 +125,10 b' pub fn pack_dirstate('
126 125 // contents of the file if the size is the same. This prevents
127 126 // mistakenly treating such files as clean.
128 127 new_mtime = -1;
129 new_state_map.push((
130 filename.to_owned(),
131 DirstateEntry {
132 mtime: new_mtime,
133 ..*entry
134 },
135 ));
128 *entry = DirstateEntry {
129 mtime: new_mtime,
130 ..*entry
131 };
136 132 }
137 133 let mut new_filename = new_filename.into_vec();
138 134 if let Some(copy) = copy_map.get(filename) {
@@ -152,8 +148,6 b' pub fn pack_dirstate('
152 148 return Err(DirstatePackError::BadSize(expected_size, packed.len()));
153 149 }
154 150
155 state_map.extend(new_state_map);
156
157 151 Ok(packed)
158 152 }
159 153 /// `now` is the duration in seconds since the Unix epoch
General Comments 0
You need to be logged in to leave comments. Login now