mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
isletter(): optimized version
Less instructions and jumps.
Saves 39 bytes.
```patch
1634,1651c1621,1628
< mov r7,a
< mov r6,a
< ; cmd_parser.c:63: return (l >= 'a' && l <= 'z') || (l >= 'A' && l <= 'Z');
< cjne r7,#0x61,00326$
< 00326$:
< mov _parse_vlan_sloc0_1_0,c
< jc 00153$
< mov a,r7
< add a,#0xff - 0x7a
< mov _parse_vlan_sloc0_1_0,c
< jnc 00149$
< 00153$:
< cjne r6,#0x41,00329$
< 00329$:
< mov _parse_vlan_sloc0_1_0,c
< jc 00132$
< mov a,r6
< add a,#0xff - 0x5a
---
> ; cmd_parser.c:66: l |= 0x20;
> ; cmd_parser.c:67: l -= 'A';
> orl a,#0x20
> ; cmd_parser.c:68: return (l <= ('Z'-'A'));
> add a,#0xbf
> add a,#0xff - 0x19
> cpl c
> ; cmd_parser.c:245: if (cmd_words_b[2] > 0 && isletter(cmd_buffer[cmd_words_b[2]])) {
1653,1654c1630
< jc 00132$
< 00149$:
---
> jnc 00132$
```
This commit is contained in:
+6
-1
@@ -60,7 +60,12 @@ __code uint8_t phys_to_log_port[6] = {
|
||||
|
||||
inline uint8_t isletter(uint8_t l)
|
||||
{
|
||||
return (l >= 'a' && l <= 'z') || (l >= 'A' && l <= 'Z');
|
||||
// return (l >= 'a' && l <= 'z') || (l >= 'A' && l <= 'Z');
|
||||
|
||||
// Make it upper case
|
||||
l |= 0x20;
|
||||
l -= 'A';
|
||||
return (l <= ('Z'-'A'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user