• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision3835 (tree)
Time2018-04-09 00:08:04
Authormagicant

Log Message

Minimize command name comparison in typeset built-in

The command name can be identified by looking only at the first
character.

Change Summary

Incremental Difference

--- yash/trunk/variable.c (revision 3834)
+++ yash/trunk/variable.c (revision 3835)
@@ -1652,19 +1652,29 @@
16521652 }
16531653 }
16541654
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);
16651675 }
16661676
1667- if (function && global && wcscmp(ARGV(0), L"typeset") == 0)
1677+ if (function && global && ARGV(0)[0] == L't' /*typeset*/)
16681678 return special_builtin_error(
16691679 mutually_exclusive_option_error(L'f', L'g'));
16701680 if (function && export)
Show on old repository browser