From 1a1faff2f67613ed0b89e1a34e6c3fd02ca6fd83 Mon Sep 17 00:00:00 2001 From: Geert-Jan Zwiers Date: Fri, 27 Jan 2023 16:16:38 +0100 Subject: [PATCH] chore(cli/cache): fewer string allocations (#17549) --- cli/cache/check.rs | 2 +- cli/cache/incremental.rs | 4 ++-- cli/cache/node.rs | 4 ++-- cli/cache/parsed_source.rs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cli/cache/check.rs b/cli/cache/check.rs index 2d9acdf518..86fb075776 100644 --- a/cli/cache/check.rs +++ b/cli/cache/check.rs @@ -192,7 +192,7 @@ fn create_tables( |row| row.get(0), ) .ok(); - if data_cli_version != Some(cli_version.to_string()) { + if data_cli_version.as_deref() != Some(&cli_version) { conn.execute("DELETE FROM checkcache", params![])?; conn.execute("DELETE FROM tsbuildinfo", params![])?; let mut stmt = conn diff --git a/cli/cache/incremental.rs b/cli/cache/incremental.rs index 2e838e85a5..652965ad77 100644 --- a/cli/cache/incremental.rs +++ b/cli/cache/incremental.rs @@ -232,7 +232,7 @@ impl SqlIncrementalCache { stmt.execute(params![ path.to_string_lossy(), &self.state_hash.to_string(), - &source_hash.to_string(), + &source_hash, ])?; Ok(()) } @@ -267,7 +267,7 @@ fn create_tables( |row| row.get(0), ) .ok(); - if data_cli_version != Some(cli_version.to_string()) { + if data_cli_version.as_deref() != Some(&cli_version) { conn.execute("DELETE FROM incrementalcache", params![])?; let mut stmt = conn .prepare("INSERT OR REPLACE INTO info (key, value) VALUES (?1, ?2)")?; diff --git a/cli/cache/node.rs b/cli/cache/node.rs index 24341e1c14..ec0121c616 100644 --- a/cli/cache/node.rs +++ b/cli/cache/node.rs @@ -253,7 +253,7 @@ impl NodeAnalysisCacheInner { let mut stmt = self.conn.prepare_cached(sql)?; stmt.execute(params![ specifier, - &source_hash.to_string(), + &source_hash, &serde_json::to_string(top_level_decls)?, ])?; Ok(()) @@ -304,7 +304,7 @@ fn create_tables(conn: &Connection, cli_version: &str) -> Result<(), AnyError> { |row| row.get(0), ) .ok(); - if data_cli_version != Some(cli_version.to_string()) { + if data_cli_version.as_deref() != Some(cli_version) { conn.execute("DELETE FROM cjsanalysiscache", params![])?; conn.execute("DELETE FROM esmglobalscache", params![])?; let mut stmt = conn diff --git a/cli/cache/parsed_source.rs b/cli/cache/parsed_source.rs index cef33e3549..6385e73844 100644 --- a/cli/cache/parsed_source.rs +++ b/cli/cache/parsed_source.rs @@ -219,7 +219,7 @@ impl ParsedSourceCacheModuleAnalyzer { stmt.execute(params![ specifier.as_str(), &media_type.to_string(), - &source_hash.to_string(), + &source_hash, &serde_json::to_string(&module_info)?, ])?; Ok(()) @@ -298,7 +298,7 @@ fn create_tables( |row| row.get(0), ) .ok(); - if data_cli_version != Some(cli_version.to_string()) { + if data_cli_version.as_deref() != Some(&cli_version) { conn.execute("DELETE FROM moduleinfocache", params![])?; let mut stmt = conn .prepare("INSERT OR REPLACE INTO info (key, value) VALUES (?1, ?2)")?;