Unverified Commit b90559cd authored by Luke Sandberg's avatar Luke Sandberg Committed by GitHub

[turbopack] Remove a bunch of dead code from the source map implementation (#84318)

The `SourceMap::Sectioned` enum was only used recursively.  once i noticed that a bunch of dead code fell out.

Part-of PACK-417
parent 031b8fb8
...@@ -1491,12 +1491,10 @@ pub async fn project_trace_source_operation( ...@@ -1491,12 +1491,10 @@ pub async fn project_trace_source_operation(
return Ok(Vc::cell(None)); return Ok(Vc::cell(None));
}; };
let token = map let token = map.lookup_token(
.lookup_token( line.saturating_sub(1),
line.saturating_sub(1), frame.column.unwrap_or(1).saturating_sub(1),
frame.column.unwrap_or(1).saturating_sub(1), );
)
.await?;
let (original_file, line, column, method_name) = match token { let (original_file, line, column, method_name) = match token {
Token::Original(token) => ( Token::Original(token) => (
......
...@@ -232,7 +232,7 @@ async fn resolve_source_mapping( ...@@ -232,7 +232,7 @@ async fn resolve_source_mapping(
let Some(sm) = &*SourceMap::new_from_rope_cached(sm).await? else { let Some(sm) = &*SourceMap::new_from_rope_cached(sm).await? else {
return Ok(ResolvedSourceMapping::NoSourceMap); return Ok(ResolvedSourceMapping::NoSourceMap);
}; };
let trace = trace_source_map(sm, line, column, name.map(|s| &**s)).await?; let trace = trace_source_map(sm, line, column, name.map(|s| &**s));
match trace { match trace {
TraceResult::Found(frame) => { TraceResult::Found(frame) => {
let lib_code = frame.file.contains("/node_modules/"); let lib_code = frame.file.contains("/node_modules/");
......
use std::{borrow::Cow, fmt::Display}; use std::{borrow::Cow, fmt::Display};
use anyhow::Result;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbopack_core::source_map::{SourceMap, Token}; use turbopack_core::source_map::{SourceMap, Token};
use turbopack_ecmascript::magic_identifier::unmangle_identifiers; use turbopack_ecmascript::magic_identifier::unmangle_identifiers;
...@@ -91,16 +90,14 @@ pub enum TraceResult { ...@@ -91,16 +90,14 @@ pub enum TraceResult {
/// memory hog, it'd be so much faster if we could just directly access /// memory hog, it'd be so much faster if we could just directly access
/// the individual sections of the JS file's map without the /// the individual sections of the JS file's map without the
/// serialization. /// serialization.
pub async fn trace_source_map( pub fn trace_source_map(
map: &SourceMap, map: &SourceMap,
line: u32, line: u32,
column: u32, column: u32,
name: Option<&str>, name: Option<&str>,
) -> Result<TraceResult> { ) -> TraceResult {
let token = map let token = map.lookup_token(line.saturating_sub(1), column.saturating_sub(1));
.lookup_token(line.saturating_sub(1), column.saturating_sub(1)) match token {
.await?;
let result = match token {
Token::Original(t) => TraceResult::Found(StackFrame { Token::Original(t) => TraceResult::Found(StackFrame {
file: Cow::Owned(t.original_file.into_owned()), file: Cow::Owned(t.original_file.into_owned()),
line: Some(t.original_line.saturating_add(1)), line: Some(t.original_line.saturating_add(1)),
...@@ -113,7 +110,5 @@ pub async fn trace_source_map( ...@@ -113,7 +110,5 @@ pub async fn trace_source_map(
.map(Cow::Owned), .map(Cow::Owned),
}), }),
_ => TraceResult::NotFound, _ => TraceResult::NotFound,
}; }
Ok(result)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment