summaryrefslogtreecommitdiff
path: root/cli/cache/incremental.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-07-10 17:45:09 -0400
committerGitHub <noreply@github.com>2023-07-10 21:45:09 +0000
commit8dd9d5f5239f9f842f7096a540f866bd4f10b72c (patch)
tree159ea977036a2ed76ce61d3ba2da9239a6f287a3 /cli/cache/incremental.rs
parent629d09b149ab42cc4c3cebc41e0f23112ace891c (diff)
refactor(lsp): move config file related code to config.rs (#19790)
Will make #19788 easier.
Diffstat (limited to 'cli/cache/incremental.rs')
-rw-r--r--cli/cache/incremental.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/cli/cache/incremental.rs b/cli/cache/incremental.rs
index c50b876fa..04ac4243b 100644
--- a/cli/cache/incremental.rs
+++ b/cli/cache/incremental.rs
@@ -72,9 +72,8 @@ impl IncrementalCacheInner {
state: &TState,
initial_file_paths: &[PathBuf],
) -> Self {
- let state_hash = FastInsecureHasher::new()
- .write_str(&serde_json::to_string(state).unwrap())
- .finish();
+ let state_hash =
+ FastInsecureHasher::hash(serde_json::to_string(state).unwrap());
let sql_cache = SqlIncrementalCache::new(db, state_hash);
Self::from_sql_incremental_cache(sql_cache, initial_file_paths)
}
@@ -114,15 +113,13 @@ impl IncrementalCacheInner {
pub fn is_file_same(&self, file_path: &Path, file_text: &str) -> bool {
match self.previous_hashes.get(file_path) {
- Some(hash) => {
- *hash == FastInsecureHasher::new().write_str(file_text).finish()
- }
+ Some(hash) => *hash == FastInsecureHasher::hash(file_text),
None => false,
}
}
pub fn update_file(&self, file_path: &Path, file_text: &str) {
- let hash = FastInsecureHasher::new().write_str(file_text).finish();
+ let hash = FastInsecureHasher::hash(file_text);
if let Some(previous_hash) = self.previous_hashes.get(file_path) {
if *previous_hash == hash {
return; // do not bother updating the db file because nothing has changed
@@ -270,7 +267,7 @@ mod test {
let sql_cache = SqlIncrementalCache::new(conn, 1);
let file_path = PathBuf::from("/mod.ts");
let file_text = "test";
- let file_hash = FastInsecureHasher::new().write_str(file_text).finish();
+ let file_hash = FastInsecureHasher::hash(file_text);
sql_cache.set_source_hash(&file_path, file_hash).unwrap();
let cache = IncrementalCacheInner::from_sql_incremental_cache(
sql_cache,