Remove one level of indirection for Context::name.
This commit is contained in:
@@ -14,7 +14,7 @@ pub fn resource() -> Result<Vec<u8>> {
|
||||
let contexts = context::contexts();
|
||||
for (id, context_lock) in contexts.iter() {
|
||||
let context = context_lock.read();
|
||||
rows.push((*id, context.name.read().clone(), context.status_reason));
|
||||
rows.push((*id, context.name.clone(), context.status_reason));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ pub fn resource() -> Result<Vec<u8>> {
|
||||
affinity,
|
||||
cpu_time_string,
|
||||
memory_string,
|
||||
*context.name.read()));
|
||||
context.name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-14
@@ -1,19 +1,8 @@
|
||||
use alloc::{
|
||||
boxed::Box,
|
||||
vec::Vec,
|
||||
};
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use crate::context;
|
||||
use crate::syscall::error::{Error, ESRCH, Result};
|
||||
use crate::syscall::error::Result;
|
||||
|
||||
pub fn resource() -> Result<Vec<u8>> {
|
||||
let name = {
|
||||
let contexts = context::contexts();
|
||||
let context_lock = contexts.current().ok_or(Error::new(ESRCH))?;
|
||||
let context = context_lock.read();
|
||||
let name = context.name.read();
|
||||
let name_bytes: Box<[u8]> = name.clone().into();
|
||||
name_bytes.into_vec()
|
||||
};
|
||||
Ok(name)
|
||||
Ok(context::current()?.read().name.clone().into_owned().into_bytes())
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ pub fn resource() -> Result<Vec<u8>> {
|
||||
let contexts = context::contexts();
|
||||
for (id, context_lock) in contexts.iter() {
|
||||
let context = context_lock.read();
|
||||
rows.push((*id, context.name.read().clone(), context.files.read().clone()));
|
||||
rows.push((*id, context.name.clone(), context.files.read().clone()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ pub fn resource() -> Result<Vec<u8>> {
|
||||
let contexts = context::contexts();
|
||||
for (id, context_lock) in contexts.iter() {
|
||||
let context = context_lock.read();
|
||||
rows.push((*id, context.name.read().clone(), context.syscall));
|
||||
rows.push((*id, context.name.clone(), context.syscall));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user