Skip to content

Commit 320a990

Browse files
paritytech-release-backport-bot[bot]karolk91github-actions[bot]
authored
[stable2409] Backport #9354 (#9372)
Backport #9354 into `stable2409` from karolk91. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> Co-authored-by: Karol Kokoszka <[email protected]> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent c5dc882 commit 320a990

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

prdoc/pr_9354.prdoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
title: Remove whitespaces added by macros due to token re-parsing
2+
doc:
3+
- audience: Runtime Dev
4+
description: |-
5+
Normalize result of `stringify` in scenarios when used inside nested macros to stringify token streams for benchmarking framework
6+
crates:
7+
- name: frame-benchmarking
8+
bump: patch

substrate/frame/benchmarking/src/v1.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,8 +1817,8 @@ pub fn show_benchmark_debug_info(
18171817
#[macro_export]
18181818
macro_rules! add_benchmark {
18191819
( $params:ident, $batches:ident, $name:path, $location:ty ) => {
1820-
let name_string = stringify!($name).as_bytes();
1821-
let instance_string = stringify!($location).as_bytes();
1820+
let pallet_string = stringify!($name).replace(" ", "").into_bytes();
1821+
let instance_string = stringify!($location).replace(" ", "").into_bytes();
18221822
let (config, whitelist) = $params;
18231823
let $crate::BenchmarkConfig {
18241824
pallet,
@@ -1827,7 +1827,7 @@ macro_rules! add_benchmark {
18271827
verify,
18281828
internal_repeats,
18291829
} = config;
1830-
if &pallet[..] == &name_string[..] {
1830+
if &pallet[..] == &pallet_string[..] {
18311831
let benchmark_result = <$location>::run_benchmark(
18321832
&benchmark[..],
18331833
&selected_components[..],
@@ -1850,7 +1850,7 @@ macro_rules! add_benchmark {
18501850
},
18511851
Err($crate::BenchmarkError::Stop(e)) => {
18521852
$crate::show_benchmark_debug_info(
1853-
instance_string,
1853+
&instance_string,
18541854
benchmark,
18551855
selected_components,
18561856
verify,
@@ -1881,8 +1881,8 @@ macro_rules! add_benchmark {
18811881

18821882
if let Some(final_results) = final_results {
18831883
$batches.push($crate::BenchmarkBatch {
1884-
pallet: name_string.to_vec(),
1885-
instance: instance_string.to_vec(),
1884+
pallet: pallet_string,
1885+
instance: instance_string,
18861886
benchmark: benchmark.clone(),
18871887
results: final_results,
18881888
});
@@ -1913,12 +1913,12 @@ macro_rules! add_benchmark {
19131913
#[macro_export]
19141914
macro_rules! list_benchmark {
19151915
( $list:ident, $extra:ident, $name:path, $location:ty ) => {
1916-
let pallet_string = stringify!($name).as_bytes();
1917-
let instance_string = stringify!($location).as_bytes();
1916+
let pallet_string = stringify!($name).replace(" ", "").into_bytes();
1917+
let instance_string = stringify!($location).replace(" ", "").into_bytes();
19181918
let benchmarks = <$location>::benchmarks($extra);
19191919
let pallet_benchmarks = BenchmarkList {
1920-
pallet: pallet_string.to_vec(),
1921-
instance: instance_string.to_vec(),
1920+
pallet: pallet_string,
1921+
instance: instance_string,
19221922
benchmarks: benchmarks.to_vec(),
19231923
};
19241924
$list.push(pallet_benchmarks)

0 commit comments

Comments
 (0)