From 79b42808a474c0a049ae17a3b6b1f93ad83d217b Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Mon, 20 Jun 2022 13:42:20 +0100 Subject: perf(core): Cache source lookups (#14816) Keep a cache for source maps and source lines. We sort of already had a cache argument for source map lookup functions but we just passed an empty map instead of storing it. Extended it to cache source line lookups as well and plugged it into runtime state. --- cli/fmt_errors.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'cli/fmt_errors.rs') diff --git a/cli/fmt_errors.rs b/cli/fmt_errors.rs index d30f661a9..37a58364a 100644 --- a/cli/fmt_errors.rs +++ b/cli/fmt_errors.rs @@ -8,8 +8,6 @@ use deno_core::error::format_file_name; use deno_core::error::JsError; use deno_core::error::JsStackFrame; -const SOURCE_ABBREV_THRESHOLD: usize = 150; - // Keep in sync with `/core/error.js`. pub fn format_location(frame: &JsStackFrame) -> String { let _internal = frame @@ -115,8 +113,7 @@ fn format_maybe_source_line( let source_line = source_line.unwrap(); // sometimes source_line gets set with an empty string, which then outputs // an empty source line when displayed, so need just short circuit here. - // Also short-circuit on error line too long. - if source_line.is_empty() || source_line.len() > SOURCE_ABBREV_THRESHOLD { + if source_line.is_empty() { return "".to_string(); } if source_line.contains("Couldn't format source line: ") { -- cgit v1.2.3