diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2022-06-20 13:42:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-20 14:42:20 +0200 |
commit | 79b42808a474c0a049ae17a3b6b1f93ad83d217b (patch) | |
tree | 937c16d6f2c5928a784ed28e60dffe18c3517643 /cli/fmt_errors.rs | |
parent | 94d369ebc65a55bd9fbf378a765c8ed88a4efe2c (diff) |
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.
Diffstat (limited to 'cli/fmt_errors.rs')
-rw-r--r-- | cli/fmt_errors.rs | 5 |
1 files changed, 1 insertions, 4 deletions
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: ") { |