perf: reduce the number of calls to git-check-attr #602

Merged
wetneb merged 2 commits from perf_git-check-attr into main 2025-10-02 10:51:36 +02:00
Owner

Follow-up to #599.

Follow-up to #599.
perf: reduce the number of calls to git-check-attr
All checks were successful
/ test (pull_request) Successful in 42s
39daeca522
mathstuf approved these changes 2025-09-30 22:08:04 +02:00
ada4a left a comment
Owner

Looking good:) Just a couple of nits

Looking good:) Just a couple of nits
@ -108,4 +113,3 @@
.current_dir(repo_dir)
.output()
.ok()
.filter(|output| output.status.success())?;
Owner

I think the question mark would still work here?

I think the question mark would still work here?
Author
Owner

The return type of the function is now HashMap<…>.

the ? operator can only be used in a function that returns Result or Option (or another type that implements FromResidual)

The return type of the function is now `HashMap<…>`. > the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
Owner

🤦‍♀️ of course

🤦‍♀️ of course
ada4a marked this conversation as resolved
src/git.rs Outdated
@ -1,6 +1,7 @@
use core::str;
use itertools::Itertools as _;
use itertools::Itertools;
Owner

I don't think this change is necessary? We're not naming the trait in the code

I don't think this change is necessary? We're not naming the trait in the code
ada4a marked this conversation as resolved
src/git.rs Outdated
@ -100,3 +101,2 @@
file_name: &Path,
attr: &str,
) -> Option<String> {
attrs: &[&'a str],
Owner

We know that 'a is actually 'static here, so I'd say let's write that to avoid complicating the function signature. We could always change that back if need arises

We know that `'a` is actually `'static` here, so I'd say let's write that to avoid complicating the function signature. We could always change that back if need arises
ada4a marked this conversation as resolved
@ -126,2 +141,3 @@
let attributes = read_attributes_for_file(repo_dir, file_name, attr_names);
read_attr("mergiraf.language").or_else(|| read_attr("linguist-language"))
attr_names
Owner

With this change, it imo becomes less intuitive that what we're doing is looking for the value of mergiraf.language first, and linguist-language second. Could you please add a small note explaining that?

With this change, it imo becomes less intuitive that what we're doing is looking for the value of `mergiraf.language` first, and `linguist-language` second. Could you please add a small note explaining that?
ada4a marked this conversation as resolved
Review feedback
All checks were successful
/ test (pull_request) Successful in 43s
df7c48e5fa
ada4a approved these changes 2025-10-02 10:45:03 +02:00
wetneb merged commit 4dcc2dbf92 into main 2025-10-02 10:51:36 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: mergiraf/mergiraf#602
No description provided.