mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-28 22:03:30 +03:00
Get performance metrics for get_wd_tree()
It's a tiny little function, but I think it can be slow as it could incur a lot of work, scaling up with the size of the repository, and the amount of untracked data in it. Let's gather some data.
This commit is contained in:
parent
ea219eedf9
commit
407ec1427b
@ -38,7 +38,7 @@ mod url;
|
||||
pub use self::url::*;
|
||||
|
||||
mod repository_ext;
|
||||
pub use repository_ext::*;
|
||||
pub use repository_ext::RepositoryExt;
|
||||
|
||||
mod tree_ext;
|
||||
pub use tree_ext::*;
|
||||
|
@ -1,14 +1,17 @@
|
||||
use anyhow::Result;
|
||||
use git2::{Repository, Tree};
|
||||
use tracing::instrument;
|
||||
|
||||
/// Extension trait for `git2::Repository`.
|
||||
///
|
||||
/// For now, it collects useful methods from `gitbutler-core::git::Repository`
|
||||
pub trait RepositoryExt {
|
||||
/// Based on the index, add all data similar to `git add .` and create a tree from it, which is returned.
|
||||
fn get_wd_tree(&self) -> Result<Tree>;
|
||||
}
|
||||
|
||||
impl RepositoryExt for Repository {
|
||||
#[instrument(level = tracing::Level::DEBUG, skip(self), err(Debug))]
|
||||
fn get_wd_tree(&self) -> Result<Tree> {
|
||||
let mut index = self.index()?;
|
||||
index.add_all(["*"], git2::IndexAddOption::DEFAULT, None)?;
|
||||
|
@ -615,8 +615,7 @@ impl Repository {
|
||||
}
|
||||
|
||||
pub fn repo(&self) -> &git2::Repository {
|
||||
let r = &self.git_repository;
|
||||
r.into()
|
||||
(&self.git_repository).into()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user