##// END OF EJS Templates
rust-dirstate: remove excessive clone() of parameter and return value...
Yuya Nishihara -
r43069:1a535313 default
parent child Browse files
Show More
@@ -68,7 +68,7 b' impl DirstateMap {'
68 self.file_fold_map = None;
68 self.file_fold_map = None;
69 self.non_normal_set.clear();
69 self.non_normal_set.clear();
70 self.other_parent_set.clear();
70 self.other_parent_set.clear();
71 self.set_parents(DirstateParents {
71 self.set_parents(&DirstateParents {
72 p1: NULL_ID,
72 p1: NULL_ID,
73 p2: NULL_ID,
73 p2: NULL_ID,
74 })
74 })
@@ -253,9 +253,9 b' impl DirstateMap {'
253 pub fn parents(
253 pub fn parents(
254 &mut self,
254 &mut self,
255 file_contents: &[u8],
255 file_contents: &[u8],
256 ) -> Result<DirstateParents, DirstateError> {
256 ) -> Result<&DirstateParents, DirstateError> {
257 if let Some(ref parents) = self.parents {
257 if let Some(ref parents) = self.parents {
258 return Ok(parents.clone());
258 return Ok(parents);
259 }
259 }
260 let parents;
260 let parents;
261 if file_contents.len() == PARENT_SIZE * 2 {
261 if file_contents.len() == PARENT_SIZE * 2 {
@@ -274,11 +274,11 b' impl DirstateMap {'
274 return Err(DirstateError::Parse(DirstateParseError::Damaged));
274 return Err(DirstateError::Parse(DirstateParseError::Damaged));
275 }
275 }
276
276
277 self.parents = Some(parents.to_owned());
277 self.parents = Some(parents);
278 Ok(parents.clone())
278 Ok(self.parents.as_ref().unwrap())
279 }
279 }
280
280
281 pub fn set_parents(&mut self, parents: DirstateParents) {
281 pub fn set_parents(&mut self, parents: &DirstateParents) {
282 self.parents = Some(parents.clone());
282 self.parents = Some(parents.clone());
283 self.dirty_parents = true;
283 self.dirty_parents = true;
284 }
284 }
@@ -298,7 +298,7 b' impl DirstateMap {'
298 )?;
298 )?;
299
299
300 if !self.dirty_parents {
300 if !self.dirty_parents {
301 self.set_parents(parents.to_owned());
301 self.set_parents(&parents);
302 }
302 }
303
303
304 Ok(Some(parents))
304 Ok(Some(parents))
@@ -320,9 +320,9 b' impl DirstateMap {'
320 Ok(packed)
320 Ok(packed)
321 }
321 }
322
322
323 pub fn build_file_fold_map(&mut self) -> FileFoldMap {
323 pub fn build_file_fold_map(&mut self) -> &FileFoldMap {
324 if let Some(ref file_fold_map) = self.file_fold_map {
324 if let Some(ref file_fold_map) = self.file_fold_map {
325 return file_fold_map.to_owned();
325 return file_fold_map;
326 }
326 }
327 let mut new_file_fold_map = FileFoldMap::new();
327 let mut new_file_fold_map = FileFoldMap::new();
328 for (filename, DirstateEntry { state, .. }) in self.state_map.borrow()
328 for (filename, DirstateEntry { state, .. }) in self.state_map.borrow()
@@ -335,7 +335,7 b' impl DirstateMap {'
335 }
335 }
336 }
336 }
337 self.file_fold_map = Some(new_file_fold_map);
337 self.file_fold_map = Some(new_file_fold_map);
338 self.file_fold_map.to_owned().unwrap()
338 self.file_fold_map.as_ref().unwrap()
339 }
339 }
340 }
340 }
341
341
@@ -243,7 +243,7 b' py_class!(pub class DirstateMap |py| {'
243
243
244 self.inner(py)
244 self.inner(py)
245 .borrow_mut()
245 .borrow_mut()
246 .set_parents(DirstateParents { p1, p2 });
246 .set_parents(&DirstateParents { p1, p2 });
247 Ok(py.None())
247 Ok(py.None())
248 }
248 }
249
249
General Comments 0
You need to be logged in to leave comments. Login now