refactor(tvix/store): use update_hasher in blobwriter
Make use of the helper function here as well. Change-Id: Ia0afd84eb3903bb897ee6aee884dc291f3e4371c Reviewed-on: https://cl.tvl.fyi/c/depot/+/8258 Reviewed-by: raitobezarius <tvl@lahfa.xyz> Autosubmit: flokli <flokli@flokli.de> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
62ecfc7001
commit
2fe7192dbc
1 changed files with 3 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
||||||
use crate::chunkservice::{upload_chunk, ChunkService};
|
use crate::chunkservice::{update_hasher, upload_chunk, ChunkService};
|
||||||
use crate::{proto, Error};
|
use crate::{proto, Error};
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
@ -59,12 +59,8 @@ impl<CS: ChunkService + std::marker::Sync> std::io::Write for BlobWriter<'_, CS>
|
||||||
// calculate input_buf.len(), we need to return that later.
|
// calculate input_buf.len(), we need to return that later.
|
||||||
let input_buf_len = input_buf.len();
|
let input_buf_len = input_buf.len();
|
||||||
|
|
||||||
// update calculate blob hash, and use rayon if data is > 128KiB.
|
// update blob hash
|
||||||
if input_buf.len() > 128 * 1024 {
|
update_hasher(&mut self.blob_hasher, input_buf);
|
||||||
self.blob_hasher.update_rayon(input_buf);
|
|
||||||
} else {
|
|
||||||
self.blob_hasher.update(input_buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepend buf with existing data (from self.buf)
|
// prepend buf with existing data (from self.buf)
|
||||||
let buf: Vec<u8> = {
|
let buf: Vec<u8> = {
|
||||||
|
|
Loading…
Reference in a new issue