Skip to content

Commit 3612735

Browse files
committed
refactor: simplify binary blob check and streamline default implementations for UastIndexConfig and SearchIndexConfig
1 parent 5db3f83 commit 3612735

3 files changed

Lines changed: 4 additions & 23 deletions

File tree

crates/gitbase-git/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub fn read_blob(repo: &Repository, blob_hash: &str, max_bytes: u64) -> Result<B
158158

159159
fn is_binary_blob(data: &[u8]) -> bool {
160160
let sample_len = data.len().min(8000);
161-
if data[..sample_len].iter().any(|byte| *byte == 0) {
161+
if data[..sample_len].contains(&0) {
162162
return true;
163163
}
164164
std::str::from_utf8(data).is_err()

crates/gitbase-loader/src/lib.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,11 @@ pub struct BlobHydrationReport {
5656
pub missing: usize,
5757
}
5858

59-
#[derive(Debug, Clone)]
59+
#[derive(Debug, Default, Clone)]
6060
pub struct UastIndexConfig {
6161
pub max_candidates: Option<i64>,
6262
}
6363

64-
impl Default for UastIndexConfig {
65-
fn default() -> Self {
66-
Self {
67-
max_candidates: None,
68-
}
69-
}
70-
}
71-
7264
#[derive(Debug, Default, Clone)]
7365
pub struct UastIndexReport {
7466
pub parsed: usize,
@@ -77,19 +69,11 @@ pub struct UastIndexReport {
7769
pub skipped_unsupported_language: usize,
7870
}
7971

80-
#[derive(Debug, Clone)]
72+
#[derive(Debug, Default, Clone)]
8173
pub struct SearchIndexConfig {
8274
pub max_candidates: Option<i64>,
8375
}
8476

85-
impl Default for SearchIndexConfig {
86-
fn default() -> Self {
87-
Self {
88-
max_candidates: None,
89-
}
90-
}
91-
}
92-
9377
#[derive(Debug, Default, Clone)]
9478
pub struct SearchIndexReport {
9579
pub indexed: usize,

crates/gitbase-pgwire/src/handler.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,7 @@ impl GitbaseHandler {
138138
)
139139
.await
140140
.map_err(|e| {
141-
PgWireError::ApiError(Box::new(std::io::Error::new(
142-
std::io::ErrorKind::Other,
143-
e.to_string(),
144-
)))
141+
PgWireError::ApiError(Box::new(std::io::Error::other(e.to_string())))
145142
})?;
146143

147144
Ok(())

0 commit comments

Comments
 (0)