Repository: rust-lang/rust
File: compiler/rustc_query_impl/src/plumbing.rs (Rust)

Code before:
            if complete { Ok(job_map_out) } else { Err(job_map_out) }
        }

        /// All self-profiling events generated by the query engine use
        /// virtual `StringId`s for their `event_id`. This method makes all
        /// those virtual `StringId`s point to actual strings.
        ///
        /// If we are recording only summary data, the ids will point to
        /// just the query names. If we are recording query keys too, we
        /// allocate the corresponding strings here.
        pub fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) {
            if !tcx.prof.enabled() {
                return;
            }

            let _prof_timer = tcx.sess.prof.generic_activity("self_profile_alloc_query_strings");

            let mut string_cache = QueryKeyStringCache::new();

            $(
                $crate::profiling_support::alloc_self_profile_query_strings_for_query_cache(
                    tcx,
                    stringify!($name),
                    &tcx.query_system.query_vtables.$name.cache,
                    &mut string_cache,
                );
            )*

            tcx.sess.prof.store_query_cache_hits();
        }

        fn encode_all_query_results<'tcx>(
            tcx: TyCtxt<'tcx>,
            encoder: &mut CacheEncoder<'_, 'tcx>,
            query_result_index: &mut EncodedDepNodeIndex,
        ) {
            $(
                item_if_cache_on_disk! {
                    [$($modifiers)*]
                    $crate::plumbing::encode_query_results(
                        tcx,
                        &tcx.query_system.query_vtables.$name,
                        encoder,
                        query_result_index,
                    )
                }
            )*
        }

        pub fn query_key_hash_verify_all<'tcx>(tcx: TyCtxt<'tcx>) {
            if tcx.sess.opts.unstable_opts.incremental_verify_ich || cfg!(debug_assertions) {

Review comment (suggestion):
Another potential drawback is that all these hundreds of function calls can now potentially be inlined and bloat `rustc_query_impl`, but if the benchmarks don't show anything, then it's not an issue in practice.

Code after:
                if res.is_none() {
                    complete = false;
                }
            )*

            if complete { Ok(job_map_out) } else { Err(job_map_out) }
        }

        /// All self-profiling events generated by the query engine use
        /// virtual `StringId`s for their `event_id`. This method makes all
        /// those virtual `StringId`s point to actual strings.
        ///
        /// If we are recording only summary data, the ids will point to
        /// just the query names. If we are recording query keys too, we
        /// allocate the corresponding strings here.
        pub fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) {
            if !tcx.prof.enabled() {
                return;
            }

            let _prof_timer = tcx.sess.prof.generic_activity("self_profile_alloc_query_strings");

            let mut string_cache = QueryKeyStringCache::new();

            $(
                $crate::profiling_support::alloc_self_profile_query_strings_for_query_cache(
                    tcx,
                    stringify!($name),
                    &tcx.query_system.query_vtables.$name.cache,
                    &mut string_cache,
                );
            )*

            tcx.sess.prof.store_query_cache_hits();
        }

        fn encode_all_query_results<'tcx>(
            tcx: TyCtxt<'tcx>,
            encoder: &mut CacheEncoder<'_, 'tcx>,
            query_result_index: &mut EncodedDepNodeIndex,
        ) {
            $(
                item_if_cache_on_disk! {
                    [$($modifiers)*]
                    $crate::plumbing::encode_query_results(
                        tcx,
                        &tcx.query_system.query_vtables.$name,
                        encoder,
                        query_result_index,
                    )
                }