Explorar o código

Merge branch 'master' of github.com:ogham/exa

Conflicts:
	unix.rs
Ben S %!s(int64=11) %!d(string=hai) anos
pai
achega
03bf728a1e
Modificáronse 1 ficheiros con 4 adicións e 13 borrados
  1. 4 13
      unix.rs

+ 4 - 13
unix.rs

@@ -123,22 +123,13 @@ impl Unix {
     pub fn load_group(&mut self, gid: u32) {
         match unsafe { c::getgrgid(gid).to_option() } {
             None => {
-                self.group_names.insert(gid, None);
-                self.groups.insert(gid, false);
+                self.group_names.find_or_insert(gid, None);
+                self.groups.find_or_insert(gid, false);
             },
             Some(r) => {
                 let group_name = unsafe { Some(from_c_str(r.gr_name)) };
-                self.group_names.insert(gid, group_name.clone());
-
-                // Calculate whether we are a member of the
-                // group. Now's as good a time as any as we've
-                // just retrieved the group details.
-                
-                if !self.groups.contains_key(&gid) {
-                    self.groups.insert(gid, Unix::group_membership(r.gr_mem, &self.username));
-                }
-
-                self.group_names.insert(gid, group_name);
+                self.groups.find_or_insert(gid, Unix::group_membership(r.gr_mem, &self.username));
+                self.group_names.find_or_insert(gid, group_name);
             }
         }