Minimize command name comparison in typeset built-in
The command name can be identified by looking only at the first
character.
@@ -1652,19 +1652,29 @@ | ||
1652 | 1652 | } |
1653 | 1653 | } |
1654 | 1654 | |
1655 | - if (wcscmp(ARGV(0), L"export") == 0) { | |
1656 | - global = true; | |
1657 | - if (!unexport) | |
1658 | - export = true; | |
1659 | - } else if (wcscmp(ARGV(0), L"readonly") == 0) { | |
1660 | - global = readonly = true; | |
1661 | - } else if (wcscmp(ARGV(0), L"set") == 0) { | |
1662 | - global = true; | |
1663 | - } else { | |
1664 | - assert(wcscmp(ARGV(0), L"typeset") == 0); | |
1655 | + switch (ARGV(0)[0]) { | |
1656 | + case L'e': | |
1657 | + assert(wcscmp(ARGV(0), L"export") == 0); | |
1658 | + global = true; | |
1659 | + if (!unexport) | |
1660 | + export = true; | |
1661 | + break; | |
1662 | + case L'r': | |
1663 | + assert(wcscmp(ARGV(0), L"readonly") == 0); | |
1664 | + global = readonly = true; | |
1665 | + break; | |
1666 | + case L's': | |
1667 | + assert(wcscmp(ARGV(0), L"set") == 0); | |
1668 | + global = true; | |
1669 | + break; | |
1670 | + case L't': | |
1671 | + assert(wcscmp(ARGV(0), L"typeset") == 0); | |
1672 | + break; | |
1673 | + default: | |
1674 | + assert(false); | |
1665 | 1675 | } |
1666 | 1676 | |
1667 | - if (function && global && wcscmp(ARGV(0), L"typeset") == 0) | |
1677 | + if (function && global && ARGV(0)[0] == L't' /*typeset*/) | |
1668 | 1678 | return special_builtin_error( |
1669 | 1679 | mutually_exclusive_option_error(L'f', L'g')); |
1670 | 1680 | if (function && export) |