Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/react_compiler/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,6 @@ impl<K: Copy + Into<u32>, V> IdMap<K, V> {
pub(crate) fn values(&self) -> slice::Iter<'_, V> {
self.0.values()
}
#[inline]
pub(crate) fn values_mut(&mut self) -> slice::IterMut<'_, V> {
self.0.values_mut()
}
}

impl<K, V> Default for IdMap<K, V> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,18 @@ fn fbt_tags() -> HashMap<Vec<u8>, MacroDefinition> {
tags
}

/// Main entry point. Returns the set of identifier IDs that are fbt/macro operands.
pub(crate) struct MacroOperands {
/// The identifier IDs that are fbt/macro operands. TS: the returned `macroValues`.
pub(crate) values: HashSet<IdentifierId>,
/// Not in upstream: operands that must print inside the macro call, not `fbt.param()` values.
pub(crate) inline: HashSet<IdentifierId>,
}

/// Main entry point.
pub(crate) fn memoize_fbt_and_macro_operands_in_same_scope(
func: &HirFunction,
env: &mut Environment,
) -> HashSet<IdentifierId> {
) -> MacroOperands {
// Phase 1: Build macro kinds map from built-in FBT tags + custom macros
let mut macro_kinds: HashMap<Vec<u8>, MacroDefinition> = fbt_tags();
if let Some(ref custom_macros) = env.config.custom_macros {
Expand All @@ -111,7 +118,10 @@ pub(crate) fn memoize_fbt_and_macro_operands_in_same_scope(
// Phase 3: Reverse data-flow to merge arguments of macro invocations
let macro_values = merge_macro_arguments(func, env, &mut macro_tags, &macro_kinds);

macro_values
MacroOperands {
values: macro_values,
inline: macro_tags.iter().map(|(id, _)| id).collect(),
}
}

/// Forward data-flow analysis to identify all macro tags, including
Expand Down
8 changes: 6 additions & 2 deletions src/react_compiler/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ fn run_hir_passes(
if env.config.enable_function_outlining {
timed!(
"OutlineFunctions",
crate::optimization::outline_functions(hir, env, &fbt_operands)
crate::optimization::outline_functions(hir, env, &fbt_operands.values)
);
}

Expand Down Expand Up @@ -652,7 +652,11 @@ fn run_hir_passes(
);
timed!(
"PromoteUsedTemporaries",
crate::reactive_scopes::promote_used_temporaries(&mut reactive_fn, env)
crate::reactive_scopes::promote_used_temporaries(
&mut reactive_fn,
env,
&fbt_operands.inline
)
);
timed!(
"ExtractScopeDeclarationsFromDestructuring",
Expand Down
Loading
Loading