Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback: Code review by golangmalaysia #8

Open
4 of 12 tasks
allaboutevemirolive opened this issue Jun 21, 2024 · 1 comment
Open
4 of 12 tasks

Feedback: Code review by golangmalaysia #8

allaboutevemirolive opened this issue Jun 21, 2024 · 1 comment

Comments

@allaboutevemirolive
Copy link
Owner

allaboutevemirolive commented Jun 21, 2024

Click to expand feedback

Err(TSimpleError::new(2, "Cannot read target link to symlink"))

Here the internal error is swallowed and replaced by a vague error message. Would be better if it’s retained in your error type for easier debugging.
And Result::map_err might be useful here.


self.abs.clone()

Can just return references to borrowed values like Option<&Path> and let users clone or to_owned or whatever. Same to other accessors.


pub trait IntoBranch<W: Write> {

When I see IntoXxx, I would expect a method receiving self not &mut self. Try a better name?


https://docs.rs/serde_with/3.8.1/serde_with/struct.DisplayFromStr.html
try this


Ivan:

Replace Box with anyhow


Not sure if being parallel would be useful, maybe can look into rayon par_bridge.


#[derive(Debug)]
pub struct Buffer<W: Write> {
    pub bufwr: io::BufWriter<W>,
}

stdout is buffered, no need to do double buffering.


aa
If you want to make it faster, can try to reduce allocations by not allocating within a loop.

2 collect there in one place, maybe can try to put vec in outer function and reuse it to reduce allocations.

This part I think can try to use rayon scope to parallelize stuff and make it faster, but not sure how easy.


aaa

Also this doing unnecessary work to first serialize it to json and then modify the json. But this is not on the hot path so doesn't really matter.


Ang:

You use visitor pattern to iterate through the d(ir)ents.

The terms are orthogonal, not interchangable.

Represent[ing] an operation to be performed on elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.

Yeah, I don't see how that applies to ls-tree. (without over complicating things. You're just doing a treewalk)


aplatform

why you hardcode unix permissions, when you don't need it to render a tree?

allaboutevemirolive: I guess this is where github workflow failed to build for windows :)


asize

Dates not in ISO format.


Dates not in ISO format.

Tracker

@allaboutevemirolive
Copy link
Owner Author

See PR #19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant