Skip to content

Commit

Permalink
chore(cli/cache): fewer string allocations (denoland#17549)
Browse files Browse the repository at this point in the history
  • Loading branch information
GJZwiers committed Jan 27, 2023
1 parent 7f38f30 commit 1a1faff
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cli/cache/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cli/cache/incremental.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down Expand Up @@ -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)")?;
Expand Down
4 changes: 2 additions & 2 deletions cli/cache/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cli/cache/parsed_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down Expand Up @@ -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)")?;
Expand Down

0 comments on commit 1a1faff

Please sign in to comment.