On Tue, Aug 9, 2011 at 7:33 PM, Rich Felker <[email protected]> wrote: > On Tue, Aug 09, 2011 at 09:37:58AM +0200, Denys Vlasenko wrote: >> #define isalnum(a) bb_ascii_isalnum(a) >> static ALWAYS_INLINE int bb_ascii_isalnum(unsigned char a) >> { >> unsigned char b = a - '0'; >> if (b <= 9) >> return (b <= 9); >> b = (a|0x20) - 'a'; >> return b <= 'z' - 'a'; >> } > > I'm scared to ask why this is written in such an obfuscated way rather > than just > > return a-'0'<10U || (a|32)-'a'<26U;
Tried it. Bloatcheck: function old new delta next_token 842 912 +70 parse_dollar 731 782 +51 grep_file 1198 1241 +43 do_cmd 4284 4320 +36 expand 659 683 +24 buffer_fill_and_print 179 196 +17 gethdr 153 169 +16 find_range 522 538 +16 act 181 197 +16 sane_address 67 79 +12 sane 57 69 +12 is_well_formed_var_name 66 78 +12 httpd_main 763 775 +12 kill_main 906 917 +11 skip_thing 289 299 +10 setlocalenv 89 99 +10 handle_errors 69 79 +10 endofname 48 58 +10 readtoken1 3204 3212 +8 is_assignment 136 144 +8 get_key 466 474 +8 bb_strtoull 76 84 +8 bb_strtoul 78 86 +8 bb_strtoll 84 92 +8 bb_strtol 85 93 +8 BB_isalnum 39 47 +8 tftpd_main 546 551 +5 lzo1x_optimize 1429 1434 +5 fail_hunk 129 132 +3 xstrtoul_range_sfx 230 231 +1 decode_one_format 715 713 -2 bb__parsespent 119 117 -2 test_main 253 247 -6 pstree_main 318 312 -6 varvalue 760 752 -8 lzo1x_1_compress 240 231 -9 lzo1x_1_15_compress 240 231 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 30/7 up/down: 466/-42) Total: 424 bytes Example of code difference: 00000000 <BB_isalnum>: 31 c9 xor %ecx,%ecx 3d ff 00 00 00 cmp $0xff,%eax -77 1b ja 24 <BB_isalnum+0x24> +77 23 ja 2c <BB_isalnum+0x2c> 88 c2 mov %al,%dl -8d 42 d0 lea -0x30(%edx),%eax +0f b6 c0 movzbl %al,%eax +83 e8 30 sub $0x30,%eax b9 01 00 00 00 mov $0x1,%ecx -3c 09 cmp $0x9,%al -76 0d jbe 24 <BB_isalnum+0x24> +83 f8 09 cmp $0x9,%eax +76 11 jbe 2c <BB_isalnum+0x2c> 83 ca 20 or $0x20,%edx -8d 42 9f lea -0x61(%edx),%eax +0f b6 c2 movzbl %dl,%eax +83 e8 61 sub $0x61,%eax 31 c9 xor %ecx,%ecx -3c 19 cmp $0x19,%al +83 f8 19 cmp $0x19,%eax 0f 96 c1 setbe %cl 88 c8 mov %cl,%al c3 ret _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
