summaryrefslogtreecommitdiff
path: root/rust/helpers/err.c
diff options
context:
space:
mode:
authorI Hsin Cheng <richard120310@gmail.com>2025-07-08 10:00:13 +0800
committerTheodore Ts'o <tytso@mit.edu>2025-07-17 10:41:05 -0400
commit9d9076238fe9fe45257f298bf51b35aa796cf0f1 (patch)
tree2fbbdd458785bfadaeab56cf952b93ecf8cbeb70 /rust/helpers/err.c
parentb12f423d598fd874df9ecfb2436789d582fda8e6 (diff)
ext4: Refactor breaking condition for xattr_find_entry()
Refactor the condition for breaking the loop within xattr_find_entry(). Elimate the usage of "<=" and take condition shortcut when "!cmp" is true. Originally, the condition was "(cmp <= 0 && (sorted || cmp == 0))", which means after it knows "cmp <= 0" is true, it has to check the value of "sorted" and "cmp". The checking of "cmp" here would be redundant since it has already checked it. Observing from the logic, when "cmp == 0" the branch is going to be true, no need to check "cmp == 0" again, so we only need to take shortcut when "cmp == 0", on the other hand, we'll check "sorted" when "cmp < 0". The refactor can shrink the generated code size by 44 bytes. Numerous instructions can be saved thus should also benefit execution efficiency as well. $ ./scripts/bloat-o-meter vmlinux_old vmlinux_new add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-44 (-44) Function old new delta xattr_find_entry 300 256 -44 Total: Before=22989434, After=22989390, chg -0.00% The test is done on kernel version 6.16 with x86_64 defconfig and gcc 13.3.0. Signed-off-by: I Hsin Cheng <richard120310@gmail.com> Link: https://patch.msgid.link/20250708020013.175728-1-richard120310@gmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'rust/helpers/err.c')
0 files changed, 0 insertions, 0 deletions