Patchwork [03,of,11] rust-dirstate: remove too abstracted way of getting &[u8]

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 17, 2019, 12:12 p.m.
Message ID <8f7737800ff279e68862.1566043924@mimosa>
Download mbox | patch
Permalink /patch/41325/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 17, 2019, 12:12 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1566016950 -32400
#      Sat Aug 17 13:42:30 2019 +0900
# Node ID 8f7737800ff279e6886250b8e2a21e67d7492937
# Parent  e04eef69a482c886117a6aaa604d8dce6e3e1d3a
rust-dirstate: remove too abstracted way of getting &[u8]

Patch

diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs b/rust/hg-core/src/dirstate/dirstate_map.rs
--- a/rust/hg-core/src/dirstate/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -130,8 +130,7 @@  impl DirstateMap {
         }
 
         if let Some(ref mut file_fold_map) = self.file_fold_map {
-            file_fold_map
-                .remove::<Vec<u8>>(filename.to_ascii_uppercase().as_ref());
+            file_fold_map.remove(&filename.to_ascii_uppercase());
         }
         self.state_map.insert(
             filename.to_owned(),
@@ -153,10 +152,7 @@  impl DirstateMap {
         filename: &[u8],
         old_state: EntryState,
     ) -> Result<bool, DirstateMapError> {
-        let exists = self
-            .state_map
-            .remove::<Vec<u8>>(filename.to_owned().as_ref())
-            .is_some();
+        let exists = self.state_map.remove(filename).is_some();
 
         if exists {
             if old_state != EntryState::Removed {
@@ -169,11 +165,9 @@  impl DirstateMap {
             }
         }
         if let Some(ref mut file_fold_map) = self.file_fold_map {
-            file_fold_map
-                .remove::<Vec<u8>>(filename.to_ascii_uppercase().as_ref());
+            file_fold_map.remove(&filename.to_ascii_uppercase());
         }
-        self.non_normal_set
-            .remove::<Vec<u8>>(filename.to_owned().as_ref());
+        self.non_normal_set.remove(filename);
 
         Ok(exists)
     }
@@ -251,12 +245,12 @@  impl DirstateMap {
 
     pub fn has_tracked_dir(&mut self, directory: &[u8]) -> bool {
         self.set_dirs();
-        self.dirs.as_ref().unwrap().contains(directory.as_ref())
+        self.dirs.as_ref().unwrap().contains(directory)
     }
 
     pub fn has_dir(&mut self, directory: &[u8]) -> bool {
         self.set_all_dirs();
-        self.all_dirs.as_ref().unwrap().contains(directory.as_ref())
+        self.all_dirs.as_ref().unwrap().contains(directory)
     }
 
     pub fn parents(