0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-12 16:59:32 -05:00

Use static dispatch

This commit is contained in:
gurv-s 2019-06-08 09:39:32 +05:30 committed by Ryan Dahl
parent 5960e398ec
commit c0b28dc224

View file

@ -137,10 +137,10 @@ impl SourceMap {
} }
} }
fn frame_apply_source_map( fn frame_apply_source_map<G: SourceMapGetter>(
frame: &StackFrame, frame: &StackFrame,
mappings_map: &mut CachedMaps, mappings_map: &mut CachedMaps,
getter: &dyn SourceMapGetter, getter: &G,
) -> StackFrame { ) -> StackFrame {
let maybe_sm = get_mappings(frame.script_name.as_ref(), mappings_map, getter); let maybe_sm = get_mappings(frame.script_name.as_ref(), mappings_map, getter);
let frame_pos = ( let frame_pos = (
@ -181,9 +181,9 @@ fn frame_apply_source_map(
} }
} }
pub fn apply_source_map( pub fn apply_source_map<G: SourceMapGetter>(
js_error: &JSError, js_error: &JSError,
getter: &dyn SourceMapGetter, getter: &G,
) -> JSError { ) -> JSError {
let mut mappings_map: CachedMaps = HashMap::new(); let mut mappings_map: CachedMaps = HashMap::new();
let mut frames = Vec::<StackFrame>::new(); let mut frames = Vec::<StackFrame>::new();
@ -232,9 +232,9 @@ fn builtin_source_map(script_name: &str) -> Option<Vec<u8>> {
} }
} }
fn parse_map_string( fn parse_map_string<G: SourceMapGetter>(
script_name: &str, script_name: &str,
getter: &dyn SourceMapGetter, getter: &G,
) -> Option<SourceMap> { ) -> Option<SourceMap> {
builtin_source_map(script_name) builtin_source_map(script_name)
.or_else(|| getter.get_source_map(script_name)) .or_else(|| getter.get_source_map(script_name))
@ -243,10 +243,10 @@ fn parse_map_string(
}) })
} }
fn get_mappings<'a>( fn get_mappings<'a, G: SourceMapGetter>(
script_name: &str, script_name: &str,
mappings_map: &'a mut CachedMaps, mappings_map: &'a mut CachedMaps,
getter: &dyn SourceMapGetter, getter: &G,
) -> &'a Option<SourceMap> { ) -> &'a Option<SourceMap> {
mappings_map mappings_map
.entry(script_name.to_string()) .entry(script_name.to_string())