From bc775c48c92bc524384dc0e31f39022073aa70af Mon Sep 17 00:00:00 2001 From: Yanray Wang Date: Wed, 16 Aug 2023 15:59:55 +0800 Subject: [PATCH] code_size_compare: handle deleted files and new files properly 'Removed' and 'NotCreated' should be displayed in new and old column respectively. The value of delta is reflected on change column. This commit handles the corner cases properly. Signed-off-by: Yanray Wang --- scripts/code_size_compare.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/code_size_compare.py b/scripts/code_size_compare.py index 52e0345c33..53d859edfa 100755 --- a/scripts/code_size_compare.py +++ b/scripts/code_size_compare.py @@ -644,13 +644,15 @@ class CodeSizeGeneratorWithSize(CodeSizeGenerator): delta = new_attr - old_attr change_attr = '{0:{1}}'.format(delta, '+' if delta else '') elif old_size: - new_attr = - old_size.__dict__[sect] + new_attr = 'Removed' old_attr = old_size.__dict__[sect] - change_attr = 'Removed' + delta = - old_attr + change_attr = '{0:{1}}'.format(delta, '+' if delta else '') elif new_size: new_attr = new_size.__dict__[sect] old_attr = 'NotCreated' - change_attr = 'None' + delta = new_attr + change_attr = '{0:{1}}'.format(delta, '+' if delta else '') else: # Should never happen new_attr = 'Error'